Let's say I have this class Logger that is logging strings in a low-priority worker thread, which isn't a background thread. Strings are queued in Logger.WriteLine and munched in Logger.Worker. No queued strings are allowed to be lost. Roughly like this (implementation, locking, synchronizing, etc. omitted for clarity):
public class Log...
Hello all
I have a feature whereby a class in a dll displays a form asking a user to clear a fault on a printer before clicking a button to say "Retry". The users have been just hitting retry without bothering to clear the fault so I am now coding an interlock:
The button on the invoked form is disabled until a call is made to an 'enab...
I am trying to get an overview of the thread safety theory behind the collections in C#.
Why are there no concurrent collections as there are in Java? (java docs). Some collections appear thread safe but it is not clear to me what the position is for example with regard to:
compound operations,
safety of using iterators,
write opera...
After reading about Erlang's lighweight processes I was pretty much sure that they were "green threads". Until I read that there are differences between green threads and Erlang's processes. But I don't get it.
What are the actual differences?
...
I'm working an application of which only one instance must exist at any given time. There are several possibilities to accomplish this:
Check running processes for one matching our EXE's name (unreliable)
Find the main window (unreliable, and I don't always have a main window)
Create a mutex with a unique name (GUID)
The mutex option...
My scenario is as follows:
I am implementing a server that must timeout or produce a response within the specified timeout period for each request. Thus each request is ensured a response from the server's point of view (the response, of course, might not reach the client due to transport layer failure, etc...).
In order to implement t...
I have c# app that has UI and background threads. Based on user input I like to stop and start the background thread. I have two options here as I see:
1) totally stop and then start background thread as new thread ( I have not been able to this. I keep getting my process ended message)
2) Pause the background thread until user click r...
I'm trying to implement a service with Twisted that's fairly close to the "finger" tutorial found here: http://twistedmatrix.com/documents/current/core/howto/tutorial/intro.html
I've got a basic.LineListener waiting for a command and then executing it, then I have a client connecting and issuing commands. Trouble is that the command som...
How would I Start and stop a separate thread from within another thread?
loop_a_stopped = true
loop_a = Thread.new do
loop do
Thread.stop if loop_a_stopped
# Do stuff
sleep 3
end
end
loop_b = Thread.new do
loop do
response = ask("> ")
case response.strip.downcase
when "s...
Hi
I implementing a high performance thread safe component, using no lock statements, only volatile and Interlocked are used for performance reasons.
I have volatile reference-type member in a class, that contains thread safe instance.
This instance is thread safe only for a couple of operations, and not for another.
Because of that an...
I'm using a SynchronizationContext to marshal events back to the UI thread from my DLL that does a lot of multi-threaded background tasks.
I know the singleton pattern isn't a favorite, but I'm using it for now to store a reference of the UI's SynchronizationContext when you create foo's parent object.
public class Foo
{
public event ...
Are client stubs generated from WSDL by Axis2 thread-safe?
Of course, "thread-safe" isn't necessary a rigorously defined term, so I'm at least interested in the following:
Are different instances of the same stub class accessible concurrently by different threads, with the same effective behavior as single-threaded execution?
Is a sin...
Are client stubs generated from WSDL by .NET WSE thread-safe?
Of course, "thread-safe" isn't necessary a rigorously defined term, so I'm at least interested in the following:
Are different instances of the same stub class accessible concurrently by different threads, with the same effective behavior as single-threaded execution?
Is a ...
Hi,
I am wanting to write some web services using WCF.
I would like to have a "thread pool" in my web service.
For example, I have nearly 6gb of data I need to manipulate.
I would like the client to call an operation on the webservice and have a new task or thread created. The client is able to call a ListRunningTasks(); and have the ...
I'm importing a portion of existing code into my Qt app and noticed a sleep function in there. Now after doing some researching I read that this type of function has no place in event programming. What should I do instead? Also, I am aware of QThread::sleep() [static protected] and subclassing it but I heard thats a hack and ends up d...
I have the following problem.
I have two classes, in this case A and B, which both own a concurrent_queue. The assumption here is that concurrent_queue is a thread-safe queue, with a blocking push() function. When an object is enqueued in B, it accesses the singleton A and it is queued up in A as well. This has the effect that a whole b...
Hi,
what the difference when the number of threads is determined, as e.g.:
for (i*10){
...
pthread_create(&thread[i], NULL, ThreadMain[i], (void *) xxx);
...
}
and when it is undetermined, just like this:
...
pthread_create(&threadID, NULL, ThreadMain, (void *) xxx);
...
In my case the numb...
I'm running a nightly cpu-intensitive java-application on a Ec2-server (c1.xlarge) which has 8 cores, 7,5 GB RAM (running Linux / Ubuntu 9.10 Karmic 64 bit)
The appplication is architected in such a way that a variable number of workers are constructed (each in their own thread) and fetch messages from a queue to process them.
Throug...
What does ExcecutionContext.SuppressFlow(); does?? In the following code what exactly gets suppressed??
I've this test code...
protected void btnSubmit_Click(object sender, EventArgs e)
{
Thread[] th = new Thread[100];
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
AsyncFlowControl cntrl ...
I want to display a progress bar while doing some work, but that would hang the UI and the progress bar won't update.
I have a WinForm ProgressForm with a ProgressBar that will continue indefinitely in a marquee fashion.
using(ProgressForm p = new ProgressForm(this))
{
//Do Some Work
}
Now there are many ways to solve the issue, like...