Solved

Call method from a different thread

Posted on 2008-09-30
2
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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