multithreading

Free C# eBook

Does anyone know a good (free) C# eBook for Intermediate programmers? I want something that covers generics, threads, events, delegates, etc. See also: http://stackoverflow.com/questions/391523/what-are-some-good-free-programming-books#392926 ...

How to restart thread in java?

Hi to all, I have created a program which searches for files in a source folder. If it finds any file, it processes that file and moves it to a destination folder, then looks for a new file in the source folder. It has to keep on checking the source folder for a file. I have used a thread to look for files in the source folder. The pro...

recording all the files in a large directory

Hi, I've got a number of directories with a large number of files in them (~10,000). I want to create a list of these files in my app, and have already threaded the io access so that the app doesn't freeze while they load. However if I exit the app before all files are loaded, the thread doesn't respond to the .Join() until the call t...

BlockingQueue: put() and isEmpty() do not work together?

I would like to have a SynchronousQueue where I insert elements from one thread with put(), so the input is blocked until the element is taken in another thread. In the other thread I perform lots of calculations and from time to time want to check if an element is already available, and consume it. But it seems that isEmpty() always re...

How independent are threads inside the same process?

Now, this might be a very newbie question, but I don't really have experience with multithreaded programming and I haven't fully understood how threads work compared to processes. When a process on my machine hangs, say it's waiting for some IO that never comes or something similar, I can kill and restart it because other processes aren...

NSPR locks with timeout.

I am using NSPR as my cross-platform threading library and using these locks: PRLock and PRRWLock. I want a timeout in the lock functions. So that, it should wait for 45 seconds, and if it is not able to acquire a lock within that time, the call should come out with an error. Then we can report error to the user within 45 seconds. How ...

Using threads to count the loops in C# events.

EDIT: It is not a listbox. My mistake. It is a list view. I have a list view control that's driving me nuts. It is a multi-select list box, so if the user selects 5000 rows, then de-selects them by selecting a single row, the SelectedIndexChanged fires 5001 times. This causes my app to hang. I'm trying to use threads to count the numbe...

C# : How do I get the actual item clicked from SelectedIndexChanged for a ListView control?

I'm working with a winForms app that has a listView. That listView has multi-select enabled and I have many, many items in the list (in row view). When I select the last row (i.e. item), then shift-click the 5000th row, SelectedIndexChanged fires 5000 times. If this happens, I end up in a very nasty loop. The last row clicked is not g...

Main UI windows not updating control -Cross-thread operation not valid

Ok..here is the problem I have a main UI form that has a control container that i can add some buttons item to it,and also i have a backgroundworker object that starts up a listner. When the listner events fire, i would like to create a button in that control container on the main UI form. Everything seems to work fine until i try to ad...

Is there any alternative to Application.DoEvents() for a web service.

Is there any alternative method to System.Windows.Forms.Application.DoEvents() to flush the event queue which doesn't use the System.Windows.Forms namespace? If not, is it ok to use the above method/namespace within a web service. ...

Call hierarchy of Thread.run() in Eclipse

I tend to use eclipse's "Open Call Hierarchy" function a lot, to trace where method calls are going in larger Java projects. I get irritated by Threads, as the call hierarchy shows the callers of the Thread.run() method as various internal Java threading functions, rather than the Thread.start() call which effectively led to the thread b...

C#: How do you access an integer in the main UI thread from another thread?

How do you access an integer (increment nCount++) in the main form from the method of an asynchronous callback function? I know that with methods you have to check if invoke is required, then call begininvoke for the intended method as a delegate, as to avoid an illegal threading operation, but how an you perform a simple operation such...

Unable to kill a worker thread in Silverlight

Hello, I'm working on a multi-threaded Silverlight application. The application has two threads: Main/UI and a background working thread. The UI thread should be able to kill the background thread, like so: private Thread executionThread; .... executionThread = new Thread(ExecuteStart); executionThread.Start(); .... executionThre...

In a multithreaded (Java or .Net) program, can I assume that copying a variable is atomic?

I was worrying about race conditions in an application I'm designing, when I was wondering about this question. Let's say I have a large array or collection of some sort that is managed by one component of my program, let's call that component Monitor. Its job is to regularly check if the collection is "dirty", i. e. has changed recentl...

Lockless list help!

Hi im trying to write a lockless list i got the adding part working it think but the code that extracts objects from the list does not work to good :( Well the list is not a normal list.. i have the Interface IWorkItem interface IWorkItem { DateTime ExecuteTime { get; } bool Cancelled { get; } void Execute(DateTime now); } ...

Atomicity of object references

Hi, I just came across the question - is the access of an object safely possible across threads in C#. E.g. with the code //Somewhere long ago MyClass myVar = new MyClass("First Instance"); //Then later, happening at the same time //In thread one myVar = new MyClass("Second Instance"); //In thread two myVar.PrintName(); I don't ca...

Why in C# is Queue scrambling the data in its elements?

I am completely perplexed with how my Queue is function. I am attempting (and failing) to write a small multi-threaded application to collect and display data in C#. After reading through Albahari's book and using the Consumer/Producer pattern he describes I got most of it to work except my data seems to get scrambled in the queue. B...

How to change the name of a thread

I have a server application that uses "a lot" of threads. Without wanting to get into an argument about how many threads it really should be using, it would be nice to be able to see some descriptive text in the debugger "threads" window describing what each one is, without having to click through to it and determine from the context wha...

In F#, can I have a function that is called on one thread, but returns on another?

I really want to be able to have a function pass some responsiblity to another object and then return on a different thread. I know this means the caller would not know that it had switched threads, but I REALLY want to know if there is ANY way to have the function return on a different thread than it was called on. ...

ASP.NET Threading - Double checked locking

I have an extension method on the HttpApplicationState object for getting my IoC container out of the application. This same code will also create the container if it doesn't exist. I have 2 questions: Is my code actually thread safe as I intend it to be Is this considered the best practice for dealing with the application state Cod...