By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,362 Members | 3,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,362 IT Pros & Developers. It's quick & easy.

problem regarding threads, invoke and class libraries

P: n/a
Hi,
I have a class library with some classes... One of those classes fire
events from a different thread. When I try to display the information
contained in the event args of this event in my UI, it says I can't access
my control's properties from a different thread... I wanted to use the
Invoke() method, but it's not available in my class nor in my thread... What
is the solution to this? I mean, how can I raise events like all others do,
in-proc with the form's thread?

thanks

ThunderMusic
Aug 2 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ThunderMusic <No*************************@NoSpAm.comwrote:
I have a class library with some classes... One of those classes fire
events from a different thread. When I try to display the information
contained in the event args of this event in my UI, it says I can't access
my control's properties from a different thread... I wanted to use the
Invoke() method, but it's not available in my class nor in my thread... What
is the solution to this? I mean, how can I raise events like all others do,
in-proc with the form's thread?
You need to call Invoke on a UI element. (Or anything else implementing
ISynchronizeInvoke appropriately.)

See http://www.pobox.com/~skeet/csharp/t...winforms.shtml for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 2 '06 #2

P: n/a
I'm actually not using any form in my class library, so I don't want users
of the library to call invoke on their controls each time they receive the
events... anyway, I just found the solution... I found it there :

http://www.codeproject.com/csharp/invoke_other_way.asp

it's at about half of the page...

I hope it can help someone else... ;)

Thanks for the quick answer tought...

ThunderMusic

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
ThunderMusic <No*************************@NoSpAm.comwrote:
>I have a class library with some classes... One of those classes fire
events from a different thread. When I try to display the information
contained in the event args of this event in my UI, it says I can't
access
my control's properties from a different thread... I wanted to use the
Invoke() method, but it's not available in my class nor in my thread...
What
is the solution to this? I mean, how can I raise events like all others
do,
in-proc with the form's thread?

You need to call Invoke on a UI element. (Or anything else implementing
ISynchronizeInvoke appropriately.)

See http://www.pobox.com/~skeet/csharp/t...winforms.shtml for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Aug 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.