I have the following code (cut down for readability):
Main Class:
public StartProcess()
{
Thinker th = new Thinker();
th.DoneThinking += new Thinker.ProcessingFinished(ThinkerFinished);
th.StartThinking();
}
void ThinkerFinished()
{
Console.WriteLine("Thinker finished");
}
Thinker Class:
public class Thinker
{
p...
What is the difference between a wait() and sleep() in Threads?
Is my understanding that a wait()-ing Thread is still in running mode and uses CPU cycles but a sleep()-ing does not consume any CPU cycles correct?
Why do we have both wait() and sleep(): how does their implementation vary at a lower level?
...
Is the implementation below thread-safe? If not what am I missing? Should I have the volatile keywords somewhere? Or a lock somewhere in the OnProcessingCompleted method? If so, where?
public abstract class ProcessBase : IProcess
{
private readonly object completedEventLock = new object();
private event EventHandler<ProcessComp...
I have read that we should always called a wait() from within a loop:
while (!condition) { obj.wait(); }
It works fine without a loop so why is that?
...
In WinForms, you have Control.BeginInvoke(), which means you can marshall a call from a background thread to the main UI thread that created the control's handle.
This is fine, but how (in C#) would you do this between two "standard" threads?
I have written a service bus, which has a processor thread to consume messages. I want a time...
I have a sort of plug-in model in which various complex user controls are stored in DLLs and loaded and instantiated at run time using
Activator.CreateInstanceFrom(dllpath, classname).
Since I'm loading quite a few of these I wanted to do it in the background, keeping my UI responsive, by creating a new thread to do the loading. The ...
What's the closest thing in Java (perhaps an idiom) to threading.Event in Python?
...
Hi all,
I asked this question yesterday since I wasn't receiving any data but strangely when I used wait in the destructor I started receveing notification from QSocketNotifier. The rest of the question is same. Can someone suggest something?
I have created a sample application from where separate thread is started to read and process d...
Say I'm showing the user a form, and using a BackgroundWorker to do some work behind the scenes.
When the user clicks OK, I cannot continue until the BackgroundWorker has completed.
If it hasn't finished when the user clicks Ok, I want to show a WaitCursor until it has, and then continue.
What's the best way to implement this?
I know ...
Hi,
I have a multi-thread application (in c#) that it does multiples HTTP GET to uri. Suddenly after of thousand of requests, i get timeout webException but destination server is OK if i test using browser. The code is:
public static string Get(string uri)
{
string responseData = string.Empty;
using (WebClient wc = new WebClien...
I need to determine which locks are the most-contended-for in my application code. What free tools can I use to determine this ?
...
What are the possible ways to debug deadlocking threads in a MT program, other than gdb?
...
What are the best practices/idioms should someone follow in order to avoid deadlocks?
...
I am currently working on a server application that needs to control a collection devices over a network. Because of this, we need to do a lot of parallel programming. Over time, I have learned that there are three approaches to communication between processing entities (threads/processes/applications). Regrettably, all three approaches ...
I am working on a bittorrent client. While communicating with the peers the easiest way for me to communicate with them is to spawn a new thread for each one of them. But if the user wants to keep connections with large number of peers that my cause me to spawn a lot of threads.
Another solution i thought of is have one thread to itera...
Static initializers are supposed to be executed once before the first reference to the class. It means that every time a class is accessed, a check should be performed whether the static initializers for the class are executed.
It seems that in multithreaded environment classes with non-trivial static initializers can be a source of cont...
I've got a struts2 action that responds to an AJAX request by taking some request parameters, calling a remote service that returns XML data, then transforming the data via XSL and returning the resulting XHTML via a Stream Result. The response is different depending on the given parameters.
Here is the action class with a bunch of stu...
Hi...
I had a Java program that I run thousand times based on a loop (according to the number of files to be compiled to build a linux kernel) in a bash script.
There was a performance problem since the jvm was started several times...
What i've done then is implementing a wrapper in java that does the same as my bash script, reads on...
My program uses Swing JPanel, JList, JScrollPane ...
It runs fine, but generated the following error message, and yet in the message it didn't say which line of my program caused the error, what can I do ?
=========================================================================
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIn...
Is there a better way to wait for queued threads before execute another process?
Currently I'm doing:
this.workerLocker = new object(); // Global variable
this.RunningWorkers = arrayStrings.Length; // Global variable
// Initiate process
foreach (string someString in arrayStrings)
{
ThreadPool.QueueUserWorkItem(this.DoSomething, ...