multithreading

Raise Events in .NET on the main UI thread

I'm developing a class library in .NET that other developers will consume eventually. This library makes use of a few worker threads, and those threads fire status events that will cause some UI controls to be updated in the WinForms / WPF application. Normally, for every update, you would need to check the .InvokeRequired property on W...

is wcf rest weboperationcontext.current thread safe?

Hi, I'm currently returning a stream from all my WebGet/WebInvoke decorated methods from WCF. And I also get a stream as input. I do this because I want flexibility with response & input content types. This is primarily because I need flexibility when parsing the input - it cannot be easily serialized / deserialized. However I then use...

ThreadPool.RegisterWaitForSingleObject for Compact Framework?

I must port a project to the compact framework. And can not convert to ThreadPool.RegisterWaitForSingleObject (WaitHandle, WaitOrTimerCallback, object, int, bool) What may be a alternative way for ThreadPool.RegisterWaitForSingleObject in c# lock (this.RegLock) { if (!this.WaitFlag) { this.mre.Reset(); ...

Is there any advantage of using volatile keyword in contrast to use the Interlocked class?

In other words, can I do something with a volatile variable that could not also be solved with a normal variable and the Interlocked class? ...

Updating a checkbox in Excel 2003 from a background thread in C# fails sometimes

Hi, I have created an Add-In in C# that implements user defined functions for Excel. These UDF's return immediately, but they control background asynchronous procedures. These procedures have status that needs to be monitored and presented to Excel. I have chosen to display the status using checkboxes. A background thread then update...

Why does my Perl script to decompress files slower when I use threads?

So I'm running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I've got a simple script to read 4 gzipped files containing aroud 750000 lines each. I'm using Compress::Zlib to do the uncompressing and reading of the files. I've got 2 implementations the only difference betw...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using TerminateThread() to kill that thread but it's causing it to hang sometimes. I know there is a way to use events and WaitForSingleObject() to make t...

Is ThreadPoolExecutor thread safe ?

Does the ExecutorService guarantee thread safety ? I'll be submitting jobs from different threads to the same ThreadPoolExecutor, do I have to synchronize access to the executor before interacting/submitting tasks? ...

Properly handling exceptions thrown in a thread or via the WPF dispatcher.

When a thread throws an exception that is unhandled, it terminates. What is the proper way to handle exceptions thrown on threads and how to propogate relevant exception data to other parts of the code that would need to subscribe to notifications? Is there an INotifyThreadPoorlyDesigned interface that I missed somewhere? Same applies ...

Is reading from an XmlDocument object thread safe?

I was wondering if i could safely read from an XmlDocument object using SelectNodes() and SelectSingleNode() from multiple threads with no problems. MSDN says that they are not guaranteed to be thread safe. If SelectNodes() and SelectSingleNode() do present problems running from multiple threads, could i use proper locking to avoid any...

Python threading test not working. [SOLVED]

EDIT I solved the issue by forking the process instead of using threads. From the comments and links in the comments, I don't think threading is the right move here. Thanks everyone for your assistance. FINISHED EDIT I haven't done much with threading before. I've created a few simple example "Hello World" scripts but nothing that ac...

Getting and terminating class's/threads in C#

okay, so here is what im doing: class Connection { public int SERVERID; private Thread connection; public Connection() { connection = new Thread(new ThreadStart(this.Run)); } public void Start(int serverid) { SERVERID = serverid; connection.Start(); } void Run() { w...

Waiting for Appdomain code to finish

Hi, I'm creating an Appdomain to run a piece of code that can literally be any thing. I want my host process to be able when all the word is complete but async calls/threads are blocking my efforts. My code is something like this: AppDomain ad = AppDomain.CreateDomain(...); WorkUnit mbro = (WorkUnit)ad.CreateInstanceAndUnwrap(...); mb...

How long does CreateThread take to execute?

I am reviewing code which creates a lot of threads. CreateThread documentation on Windows says that a all thread creation calls are serialized within a process. To estimate the performance impact of such code, I wonder how long does CreateThread take to run? I understand this depends on the number of DLLs already loaded into the process,...

core dump in a multithread program

Hi, i was trying to write a simple multithreaded program. It is dumping the core. I have my function that is called when a thread is created below: void *BusyWork(void *t) { int i; int *tid; int result=0; tid = t; printf("Thread %d starting...\n",*tid); for (i=0; i<10; i++) { result = result + (i* i); } ...

query about a multithreading program

this might a simple query. when we are creating a thread we are passing the (void *)t as an argument to a function PrintHello.we are copying the value in the pointer threadid(typacasting it to long) in tid which is a long variable again.i am confused with the parameter passing. is this a pass by reference or pass by value.over all is t...

Kernel threads and POSIX library

How does one create a Kernel Thread using Posix library? ...

How can I share object between threads in Perl?

I have searched for related topic, but still can't solve the problem... use threads; my $person = new Person( 'Name' => "yy"); my $udp_thread = threads->new(\&udp_func); while(1) { $person->working(); } sub udp_func { #Can't call method "setName" on an undefined value: $person->setName(); } How can I visit...

Server application have to make pings to N clients. Is there way to make it multithreaded?

I write server application (Windows Server 2003) making upto 1000 ping calls to clients and waiting for receive responses. As ping uses ICMP connection, I've found no way to define from which IP the server receives the responses. Currently I use blocking by Mutex but it practically removes all bonus of multhithreading. Is there another w...

How do I start to use multithread programming?

I am a beginner on Stack Overflow. I am working on a Unix platform in C/C++. Knowing basic programming in these regards how could I start with multithreading? Multithreading seems to be very interesting and I want to grow my knowledge in this regard. How could I get started with multithreading and what are the best techniques/books/ebo...