multithreading

How to use Threading in Change some Cell in Gridview?

How to use Threading in Change some Cell in Gridview? I have some query from database and use many time for query its. to Its very slow , then i would to used Threading for load data faster than and when thrad finish job can change data in Grid view? ...

A new sql connection for each query?

I'm writing a server application that's communication with a local sql server. Each client will need to read or write data to the database. Would it be better to have a thread safe class which will enqueue and executes the sql commands on a single sql connection? Or should I open a new connection for each command? Does it matter much f...

C# Timer / Event Race - Flushing the timers thread

Hi again, I am looking for a method where I can make sure that no callback is waiting to be executed on a System.Timers.Timer thread after I have called Stop() on it. Basically I have a timer and a async socket - Either one can invoke an appropriate function when either the time elapses or a new packet is received. Naturally I don't wa...

Bind threads to processors

Hi, When I run my multi-threaded code, the system (linux) sometimes moves the threads from one processor to another. As I have as many threads as I have processors, it invalidates caches for no good reasons and it confuses my tracing activities. Do you know how to bind threads to processors, and why does a system would do this ? ...

When should I ask myself if my method is thread-safe or not?

Hi, When should I take it into consideration whether my method is thread-safe or not? thanks, kalem keki ...

cooperative memory usage across threads?

I have an application that has multiple threads processing work from a todo queue. I have no influence over what gets into the queue and in what order (it is fed externally by the user). A single work item from the queue may take anywhere between a couple of seconds to several hours of runtime and should not be interrupted while processi...

Becoming a thread monkey

What would you suggest as a road map for becoming very proficient in writing multithreaded applications - beyond "tinkering"? I am a C# developer - would branching off into some other languages help this endeavor? Does the parallel addition to .NET 4.0 hide things that you should know in order to make it easier? ...

Standard way to wait on thread completion

What is the standard way to wait on a process in another thread to complete? In my case I have a multi-threaded service, and I want to ensure that when a service stop is requested that processing completes before service exits. Should I use a ManualResetEvent? ...

On which platforms is thread local storage limited and how much is available?

I was recently made aware that thread local storage is limited on some platforms. For example, the docs for the C++ library boost::thread read: "Note: There is an implementation specific limit to the number of thread specific storage objects that can be created, and this limit may be small." I've been searching to try and find out the ...

Are C# arrays thread safe?

In particular Create a function to take an array and an index as parameters. Create a n element array. Create a n count loop. Inside the loop on a new thread assign a new instance of the object to the array using the indexer passed in. I know how to manage the threads etc. I am interested in know if this is thread safe way of doing...

Async HttpWebRequest - thread number

Let's say I have the following code : ThreadPool.SetMinThreads(100, 100); for (int i = 0; i < 100; i++) { var request = WebRequest.Create(url); request.BeginGetResponse(ar => { //inside AsynchCallBack method for request.BeginGetResponse() var response = (HttpWebResponse)request.EndGetResponse(ar); string html; using (var ...

Understanding MsgWaitForMultipleObjects

I have a main gui thread that I want to remain responsive to the users action such as moving the dialog around, resizing, etc while I have a background thread doing some task. In the past I've used WaitForSingleObject with a timeout in order to process gui events while waiting on the background thread to complete. I recently read about...

Does C# Monitor.Wait() suffer from spurious wakeups?

Java's Object.wait() warns against "spurious wakeups" but C#'s Monitor.wait() doesn't seem to mention it at all. Seeing how Mono is implemented on top of Linux and Linux has spurious wakeups, shouldn't this be documented anywhere? ...

Properly disposing of class with thread

I have a fairly complex multi-threaded Windows service working, but I can't figure out how to clean up correctly. Below is some [pseudo] code to show what I have. The actual code is much more complex, probably too much to copy/paste here. Basically, I have a class Request that creates a thread to do the work. When a new request comes...

C# Winforms Threading - Delay Child form event until form is closed

Hi everyone.. I have an interesting problem.. I have a Form that launches another Form (2) through a Button. Before Form2 Closes, it sometimes fires an Event which Invalidates Form 1 and forces Form 1 to refresh it's data. The problem I have is After Form 2 fires the event, Form 1 seems to get it and handles it, and refreshes it's data...

C# - Is it Possible to Iterate GC Heap ?

I'm not sure whether the following questions are valid.To educate myself i am just asking. ( 1 ) Can I programmatically iterate the GC Heap of all generations ? ( 2 ) Is it possible to watch how does the GC operate on my assembly by launching a thread ? ...

Thread Creation Problem

i have defined one thread fucntion inside .cpp file and i have called createThread function to create thread it is working fine.if i declare thread function declartion in .h file and definition in .cpp file means the thread is not executing immedialty the applcation quits.i'm creating a thread from main().what is the problem in this scen...

C# - As Delegates doing Asyn task still do i need System.Threading ?

As i can perform asynchronous operations using delegates,i suspect there is a thin chance to use System.Threading in my application.Is there any essential situation where i can not avoid System.Threading ? ( Just I am in learning Phase). Example : class Program { public delegate int Total (int a,int b); static void Main() { Tot...

InkPresenter can't be called in external thread

Hi I need to convert a InkPresenter to bitmap : InkPresenter ink = new InkPresenter(); ink.Strokes = p; RenderTargetBitmap targetBitmap = new RenderTargetBitmap((int)rect.Right, (int)rect.Bottom, 96d, 96d, PixelFormats.Default); ink.Measure(new Size((int)rect.R...

Threads get stuck in MySqlCommand.ExecuteNonQuery()

I want to make the calls to a method parallel. In this method I calculate some value (very fast) and write the value of this calculation into a database table. Therefore I use a Threadpool ThreadPool.QueueUserWorkItem((state) => { method(); }); After a while of calculation (not deterministic, the time when ...