Threading

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

I have a project with a COM class.
It creates a new thread whose function loops continually.
Within the looping function I Raise an event.
When the client app (VB6) receives the event, what thread does it receive it
on and is this thread safe.
Is there a better way to raise an event from the .NET class thats on a
different thread.

-Lou
 
When the client app (VB6) receives the event, what thread does it receive it
on and is this thread safe.

Events are just like regular method calls. They are handled on the
same thread that they are raised on.

Is there a better way to raise an event from the .NET class thats on a
different thread.

Better in what way?


Mattias
 
So how should I do this?
Is it safe to do it the way I am doing it?
My VB6 client keeps crashing in the IDE. I think it's this threading issue.
The .NET object Event gets raised on a different thread than the client app
that receives it, won't this cause problems?
If so what is the correct method?

Thanks
Louie
 
Lou said:
So how should I do this?
Is it safe to do it the way I am doing it?
My VB6 client keeps crashing in the IDE. I think it's this threading
issue. The .NET object Event gets raised on a different thread than
the client app that receives it, won't this cause problems?
If so what is the correct method?

I have not much experience in it, but what I would do in order to be on the
safe side, is:
Create a hidden window in the first thread. In the other thread, call the
Form's Invoke method to marshal the action back to the first thread. There
you can raise the event.
It's a hack but as VB6 does not really support free threading it can be a
work-around.


Armin
 
Back
Top