Solved

Call method from a different thread

Posted on 2008-09-30
2
250 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server Error 11 58
Turn on intranet settings 1 56
how to read json value 2 48
VB.NET 2008 Publish Error 2 25
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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