Click here to Skip to main content
15,915,702 members
Home / Discussions / C#
   

C#

 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 18:41
JoeRip4-Jan-07 18:41 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 19:08
Phillip M. Hoff4-Jan-07 19:08 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 19:50
Phillip M. Hoff4-Jan-07 19:50 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:04
JoeRip4-Jan-07 20:04 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 20:22
Phillip M. Hoff4-Jan-07 20:22 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:31
JoeRip4-Jan-07 20:31 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:45
JoeRip4-Jan-07 20:45 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 21:05
Phillip M. Hoff4-Jan-07 21:05 
I was just finishing up an explanation of the Invoke() method and its use when my laptop decided to stage a temporary strike. Mad | :mad:

When you call Invoke(), you generally pass two things. The first is the method that should be invoked on the UI thread. It's often convenient to simply pass the method currently executing since the method we want executed on the UI thread will usually have the same signature anyway. The InvokeRequired check prevents an infinite recursion. The second argument passed is a collection of arguments to pass to the method to be executed on the UI thread. If we're "recursively" calling the same method, we just pass an object array with the arguments that the method was given in the first place. (If the list of arguments passed to Invoke() don't match the signature of the method passed to Invoke(), an exception will be thrown.)

The Invoke() method will then place a special message into the application's message queue and wait for it to be picked up and processed by the application's message pump operating on the UI thread. The message contains the method to be called and the arguments to pass to the method. The UI thread will eventually get to and process the message. As the message is processed, the UI thread will execute the specified method and pass it the specified arguments. When the method exits, the UI thread moves on to the next message in the queue and the original caller of Invoke() is notified and allowed to continue.

Finally, a lot of the confusion surrounding the use of Invoke() is exactly what you're seeing. Sometimes (often times) everything works just fine even though the UI is being updated from all manner and number of worker threads. Then you find the right scenario and everything just *stops* for no apparent reason. (I had written one application that ran for days on end when left minimized but would immediately lock up when the first event arrived while the user was actually looking at the form.) I've noticed that Visual Studio 2005 has an improved debugger that will actually (in certain situations and when configured to do so) throw exceptions in this situation so that the problem is more apparent to the developer.

-Phil
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 21:12
JoeRip4-Jan-07 21:12 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 21:25
Phillip M. Hoff4-Jan-07 21:25 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 21:34
JoeRip4-Jan-07 21:34 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 21:45
Phillip M. Hoff4-Jan-07 21:45 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 21:47
JoeRip4-Jan-07 21:47 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Luc Pattyn5-Jan-07 4:22
sitebuilderLuc Pattyn5-Jan-07 4:22 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:15
JoeRip4-Jan-07 20:15 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:20
JoeRip4-Jan-07 20:20 
QuestionVirus Pin
Tyler454-Jan-07 15:45
Tyler454-Jan-07 15:45 
AnswerRe: Virus [modified] Pin
Vega024-Jan-07 16:06
Vega024-Jan-07 16:06 
AnswerRe: Virus Pin
leppie4-Jan-07 16:54
leppie4-Jan-07 16:54 
AnswerRe: Virus Pin
Christian Graus4-Jan-07 18:03
protectorChristian Graus4-Jan-07 18:03 
QuestionRe: Virus Pin
Tyler454-Jan-07 18:58
Tyler454-Jan-07 18:58 
AnswerRe: Virus Pin
Chris Buckett4-Jan-07 21:13
Chris Buckett4-Jan-07 21:13 
AnswerRe: Virus Pin
Hamid_RT4-Jan-07 18:44
Hamid_RT4-Jan-07 18:44 
AnswerRe: Virus Pin
Tyler454-Jan-07 20:34
Tyler454-Jan-07 20:34 
GeneralRe: Virus Pin
Pete O'Hanlon4-Jan-07 22:26
mvePete O'Hanlon4-Jan-07 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.