Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Call method from a different thread

Posted on 2008-09-30
2
Medium Priority
?
255 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 1000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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