?
Solved

Call method from a different thread

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

771 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