multithreading

VS2005 c# multi threading: how to launch 10 threads

What is the best way to launch 10 threads like in a for loop for a process intensive method. A code example would be very helpful. for (int i = 0; i<=10; i++) //10 threads are intended. { LongRunningMethod(); } ...

Concurrent multithreaded READ access - Can this cause any problems?

Is there any potential for issues when having multiple threads read static values or can they be read by any number of threads concurrently without issues? (C#) ...

Best C# solution for multithreaded threadsafe read/write locking?

What is the safest (and shortest) way do lock read/write access to static members in a multithreaded environment in C#? Is it possible to do the threadsafe locking & unlocking on class level (so I don't keep repeating lock/unlock code every time static member access is needed)? Edit: Sample code would be great :) Edit: Should I use t...

In CLR, what is difference between a background and foreground thread ?

What is difference between a background and foreground thread ? ...

When to use 'volatile' or 'Thread.MemoryBarrier()' in threadsafe locking code? (C#)

When should I use volatile/Thread.MemoryBarrier() for thread safety? ...

Are threads waiting on a lock FIFO?

Let's say I have the following code static class ... { static object myobj = new object(); static void mymethod() { lock(myobj) { // my code.... } } } Then let's say that while thread1 has the lock thread2 tries to run mymethod. Will it wait for the lock to be released or throw an e...

Cross-Thread operation not valid VB.NET

I looked around the site and the questions I found relating to this subject were for C# (the application that I am maintaining is written in VB.NET), so I apologize if I overlooked one. Here is where I am calling my thread: Private Sub saveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveBtn.Click I...

using class specific set_new_handler.

For class specific new_handler implementation, i came across the following example in book "effective c++". This looks problem in multithreaded environment, My Question is how to achieve class specific new_handler in multithreaded environment? void * X::operator new(size_t size) { new_handler globalHandler = // insta...

how to restart a thread in vc++, I have created it using CreateThread

Hi All I am using vc++ and creating a thread using CreateThread function .Can I restart it again once it has returned after completing its task. ...

How to update a GUI from another thread in Java

Hi, I am writing a desktop application using SWT. What is the simplest way to update GUI controls from another thread? ...

Separation of GUI and logic in different threads in a Windows Form application

In a Windows Forms application I want to separate the GUI from the logic. The user requests are complex and involve communications so I don't want it to depend on the GUI thread. The structure should be something like: GUI -----> splash screen ---------> User Form --------------> ... | # ...

Fine grained multithreading - how much should a worker task do?

I'm using the work_pile pattern so the threads are always running and waiting on a semaphore for incoming new function pointers + data in a queue. Thats what the apple marketing guys now calls Grand Central Dispatch and promote as the new sliced bread thing. I just wonder how to find out if it is usefull to split a short task into two ...

Memory leakage in c# windows service multithreading application

I have a windows service multithreaded application for indexing purpose which have six threads. It is working fine except memory leakage. Actually when the service is started, then the service is consuming 12,584kb memory, after some time it is taking memory of 61,584 kb. But after indexing process is complete it is not releasing memory....

How to find out which threading model a DLL was built with?

Hello Writing a ASP.NET website, we have a lot of legacy components we need to rely on. My view is that because we are MTA (Multi Threaded Apartment) in ASP.NET, if we use a STA component then the requests will queue. So even if we use a .NET component which is MTA, if IT relies on an old STA component, this will still queue. Am I ri...

Passing a msg to another thread in C#

I have a thread running in the background. How do i send it messages from my main thread? The only msg i need to send is 'go'/'wakeup' ...

Return values from two long running methods, using threads

I have a thread that connects to two network resources. Each time I attempt a connection, it can take 10 seconds for a reply. void MyThread() { //this takes ten seconds Resource r1 = MySystem.GetResource(ipAddress1); //this takes ten seconds Resource r2 = MySystem.GetResource(ipAddress2); //do stuff with ep1 and...

boost::bind, boost::asio, boost::thread, and classes

sau_timer::sau_timer(int secs, timerparam f) : strnd(io), t(io, boost::posix_time::seconds(secs)) { assert(secs > 0); this->f = f; //t.async_wait(boost::bind(&sau_timer::exec, this, _1)); t.async_wait(strnd.wrap(boost::bind(&sau_timer::exec, this))); boost::thread thrd(&io,this); io.run(); //thrd(&sau_ti...

.NET C# Socket Concurrency issues

An instance of System.Net.Sockets.Socket can be shared by 2 threads so one use the send() method and another it's receive() method ? Is it safe? Well, I need it to be not only thread-safe, but also that the send/receive methods be non-syncronized, so as to let each thread call them concurrently. Do I have another way of doing it ? T...

C global static - shared among threads?

In C, declaring a variable static in the global scope makes it a global variable. Is this global variable shared among threads or is it allocated per thread? Update: If they are shared among threads, what is an easy way to make globals in a preexisting library unique to a thread/non-shared? Update2: Basically, I need to use a preexisti...

NSThread, NSTimer and AutoreleasePools in an iPhone SDK application

Hello every one, I want to create an appilication in iPhone in which I want to use NSThread. I have created one thread using [NSThread detachNewThreadSelector:@selector(doThread:) toTarget:self withObject:nil]; I want that my one thread will handle all the touches and other user interaction and the second thre...