取消
显示结果 
搜索替代 
您的意思是: 

Problem with .NET Events - What am I doing wrong?

已解决!
转到解答

Hi All,

 

I'm trying to use the System.Net.WebClient asynchronous download method (so that I can get an indication of progress for my downloads) but seem to be running into problems getting the .NET event handling to work. My current attempt (see attached VIs) ends up with a rather ugly crash but I'm not sure what I'm doing wrong.

 

Could anyone point me in the right direction?

 

Thanks,

Shaun

0 项奖励
1 条消息(共 6 条)
3,641 次查看

Hi,

 

What Windows versions are you using?  It sounds similar to the issue I'm having.  Is the error message the one you see here?

 

http://forums.ni.com/ni/board/message?board.id=170&thread.id=474834

 

One thing I noticed between XP and 7 is that LabVIEW can't get the members in e.  In XP, I could use a property node directly connected to e.

 

Thanks
John 

0 项奖励
2 条消息(共 6 条)
3,632 次查看

It definately looks like something could be similar, my error (even with all code referencing e removed, so that my callback literally sets a Value (Signalling) to the boolean control) is as follows:

 

Error.png

 

(I'm running LabVIEW 2009f3 on Windows Vista)

0 项奖励
3 条消息(共 6 条)
3,623 次查看
解答
已被主题作者 shew82 接受

Hey John,

 

After some more searching, I came up with the solution to my problem (which might solve yours also):

http://digital.ni.com/public.nsf/allkb/2AF19EBDFA4AC82D862576B6006E7FE8

 

or in short, on your callback VI, make sure the Sender and e elements of the Event Data cluster are the proper data types for your event (ie Sender = system.object and e = whatever your event's arguement's data type is).

4 条消息(共 6 条)
3,618 次查看
Thanks, that was it.
0 项奖励
5 条消息(共 6 条)
3,610 次查看

Hey Shaun and others,

 

Just stumbled upon thread. I'm now using a synchronous .NET HTTP client in LabVIEW 2010 / Win 7 and XP, want to change the client to asynchronous to be able to abort a request. I use the WebRequest class instead of the WebClient class.

 

Hope you can provide some help on this 2 years old thread.

 

The code posted in message 1 doesn't work at my side, no event is generated, the Download Complete Callback.vi is never fired and the VI never ends execution without abort button.

 

Are you able to share (parts of) your implementation?

 

My idea was to implement something similar to this example at MSDN.

 

Thanks,

Biggeveen

0 项奖励
6 条消息(共 6 条)
3,249 次查看