Solved

Call method from a different thread

Posted on 2008-09-30
2
248 Views
Last Modified: 2013-12-17
I have an application that uses 2 threads, one for calculations and one for displaying an UI. I need to call a method that is in the calculation thread from the UI thread. When I call methods located in the UI thread from the calculation thread I use Invoke, but the other way around is not working.
0
Comment
Question by:marioana
2 Comments
 
LVL 21

Accepted Solution

by:
mastoo earned 250 total points
ID: 22607176
You can't really interrupt a non-Gui thread like that, to call from another thread.  You would instead do some kind of synchronization.  For instance, your calc thread might have a queue and the gui thread enqueues "requests" on it.  The calc thread then periodically polls the queue.  You'd need some kind of sync on the queue to avoid concurrent access by both threads.

Or if the calc thread finishes and you want the gui to tell it there is more to do, the calc thread waits on a sync event that the gui can raise.
0
 
LVL 1

Author Comment

by:marioana
ID: 22648165
In the end it seems it's not a threadng problem, but my question was threading related, so I thank you for the answer.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now