|
-
Feb 20th, 2012, 06:16 PM
#6
Re: How do I use Event Handlers
 Originally Posted by Brian Henry
I am having no luck.
In what way is it not working? What do you expect to happen, and what actually happens?
 Originally Posted by Shaggy Hiker
If you raise that event from a background thread, you'll be raising it on the wrong thread.
True dat. You don't want to be messing around with Invokes in the form code if you can avoid it. You can make sure events are raised on the thread that created the UDP_Broadcast instance (presumably it is created on the UI thread?) by taking a reference to the SynchronizationContext.Current property in the constructor (add a Public Sub New() method). This will give you a SynchronixationContext instance that you can call Post or Send from the secondary thread to execute code on the first thread. These two methods are analogous to BeginInvoke and Invoke, respectively.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|