QThread::terminate() states that it is discouraged to terminate a thread by calling this function. In my program, I need to terminate a thread before it finishes execution. The thread is performing some heavy computation and I want the user to have control to stop calculation. How can I do that instead of calling QThread::terminate()?
T...
Hi community,
I have a question about event handling with C#. I listen to events a class A throws. Now when the event ist thrown a method is executed that does something. This method sometimes has to wait for respones from datasources or similar.
I think event handling is synchronous so one after another event will be processed. Is it ...
I just noticed that when changing bound properties in my ViewModel (MVVM) from a background worker thread I do not get any exceptions and the view is updated correctly. Does this mean I can savely rely on wpf databinding marshalling all changes in the ViewModel to the UI Thread? I think I have read somewhere that one should make sure (in...
I am applying my new found knowledge of threading everywhere and getting lots of surprises
Example:
I used threads to add numbers in an
array. And outcome was different every
time. The problem was that all of my
threads were updating the same
variable and were not synchronized.
What are some known thread issues?
What care...
What is this:
synchronized (this) {
// ...some code...
}
good for?
(Could you write an example?)
...
I need to submit a number of task and then wait for them until all results are available. Each of them adds a String to a Vector (that is synchronized by default). Then I need to start a new task for each result in the Vector but I need to do this only when all the previous tasks have stopped doing their job.
I want to use Java Executor...
I'd like to download a picture and afterwards show it in a picturebox.
at first I did like this:
WebClient client = new WebClient();
client.DownloadFile(url, localFile);
pictureBox2.Picture = localFile;
But that wasn't perfect because for the time while the download is performed the app is kinda freezing.
Then I changed to this:
pu...
Hi all,
I have 2 questions :
Q1) Can i implement an asynchronous timer in a single threaded application i.e i want a functionality like this.
....
Timer mytimer(5,timeOutHandler)
.... //this thread is doing some other task
...
and after 5 seconds, the timeOutHandler function is invoked.
As far as i can think this cannot be done ...
In C:
If I have 3 threads,
2 threads that are appending strings to a global char string (char*),
and 1 thread that is reading from that char string.
Let's say that the 2 threads are appending about 8 000 strings per second each and the 3rd thread is reading pretty often too.
Is there any possibility that they will append at exactly th...
The system I'm working on needs to consume an IEnumerable of work items, iterate through each of them, and in between them wait for a certain period of time. I would like to keep the system as simple as possible at the enumeration site. That is, I'd like to have a method that I can call at the end of the foreach block which will block fo...
Hi
Is there any way I can get a list of all the running Threads in the current JVM (including the Threads NOT started by my class)?
Is it also possible to get the Thread and Class objects of all Thread in the list?
I want to be able to do this through code.
...
My server/client start a new thread "readerThread()" for reading incoming tcp traffic. This thread blocks on read(). How can i exit this readerThread().
One way is to start another thread which closes the socket when the thread is to be exited so the read would exit. is there a more cleaner/better way to do it.
...
Inside my app, I want to send a message to a dialog from a different thread.
I want to pass an std::exception derived class reference to the dialog.
Something like this:
try {
//do stuff
}
catch (MyException& the_exception) {
PostMessage(MyhWnd, CWM_SOME_ERROR, 0, 0); //send the_exception or the_exception.error_string() here
}...
I've been tasked with working on a download queuing system but I'm a bit confused about where to start.
Essentially what we need to do is to have something like a download manager (but not as fully blown). We have about 20-100 files to download, we give the user a UI (with a listview) to allow them to pause, stop, or move the priorty of...
I've always been under the impression that using the ThreadPool for (let's say non-critical) short-lived background tasks was considered best practice, even in ASP.NET, but then I came across this article that seems to suggest otherwise - the argument being that you should leave the ThreadPool to deal with ASP.NET related requests.
So h...
I am using the Javamail API connecting to my IMAP server. Everything is working great with the javax.mail.Folder.idle() method. My listener gets called when a new mail comes in. However the problem is idle blocks forever, how do I interrupt it? How do I actually stop the listening without killing my java program?
I've tried calling Thre...
i am using thread.abort command to kill the thread but it not working is there any other way of terminating the thread
private void button1_Click(object sender, EventArgs e)
{
if (Reciever.IsAlive == true)
{
MessageBox.Show("Alive");
Reciever.Abort();
}
else
{
...
Is there any way to determine how many threads can specific JVM + Application Server combination handle? The question is not only about web application request serving threads, but also about background threads.
...
I am currently using select loop to manage sockets in a proxy. One of the requirements of this proxy is that if the proxy sends a message to the outside server and does not get a response in a certain time, the proxy should close that socket and try to connect to a secondary server. The closing happens in a separate thread, while the s...
For the following code I get a compile time error, *
'int' is not a reference type as
required by the lock statement
int i = 0;
lock(i);
But no errors for this:
int i = 0;
Monitor.Enter(i);
I understand that a value type shouldn't be used for locking due to the complications arising due to boxing. But, then why does it work...