multithreading

What are background, foreground & main threads ?

Hi folks, what's the difference between background, foreground & main threads? What are the diff types of threads in .NET? TIA ...

VB.net Cross-Thread

Hello, I have a cmd command that needs to be executed, when the command starts it starts to fill a progressbar. When the cmd command is done the progressbar needs to fill up to 100. This is the code i use, but it gives me an error when the progressbar.Value = 100 comes up. Public Class Form1 Dim teller As Integer Private Sub ...

Crossthread operation not valid... - VB.NET

Hello everyone... I am using vb.net, and in my program I get this 'crossthread operation not valid' error when I run my backgroundworker that will make this textbox enabled true. My main sub will first turn the enabled to false, and when the backgroundworker runs it will turn it back true then exit. Why does it give me an error? FYI: Th...

Why does the number of threads reported by WinDbg, Task Manager and VS Debugger differ?

While my .Net 3.5 app was running, the Windows Task Manager shown that my app had 16 threads. I collected a memory dump for the process and opened it using WinDbg/SOS. Running the !threads command reveals that I have : ThreadCount: 456 UnstartedThread: 0 BackgroundThread: 6 PendingThread: 0 DeadThread: 449 Hosted Runtime: no Here are...

WPF Dispatcher, Background worker and a whole lot of pain.

Ok this may be really simple but everything I try just seems to hit a brick wall. I have a view model with two properties, which are bound to my WPF form: bool IsWorking {get;set;} ObservableCollection<OtherViewModel> PendingItems {get;set;} I have a method that I call to fetch some new pending items from outlook, however I also wh...

Why does Interlocked.CompareExchange<T> only support reference types?

Disclaimer: My posts are apparently always verbose. If you happen to know the answer to the title question, feel free to just answer it without reading my extended discussion below. The System.Threading.Interlocked class provides some very useful methods to assist in writing thread-safe code. One of the more complex methods is Compare...

How do I safely access the contents of an NSArray property from a secondary thread?

I have an app (using retain/release, not GC) that maintains an NSArray instance variable, which is exposed as a property like so: @interface MyObject : NSObject { NSArray* myArray; } @property (copy) NSArray* myArray; @end I want to access the contents of this array from a secondary thread, which is detached using -performSelector...

Does JavaScript support multiple threads? If not, how should I implement sleep()?

Possible Duplicates: Sleep in Javascript Is there some way to introduce a delay in javascript? how to make a sleep in javascript? It seems no sleep() function provided, can we make one? ...

General - Number of threads in thread pool

Me and a friend were debating whether the number of threads in a threadpool should be process count + 1 or just process count. I chose just processor count because there is a even number of threads that can be distributed to each processor, and he chose processor count + 1 because he thinks it'll help him optimize performance So my que...

confused about threads in java

I understand threads in theory, but I have no idea how to implement them in Java. The circles are supposed to be threads and the rectangles are supposed to be buffers. I have this all coded but it doesn't work, so I am starting new. My source of confusion comes from the fact that I need this cycle to repeat many times and in this or...

Update WPF controls at run time

I'm trying to write a WPF application that will update a set of text boxes and labels at run time using threads but the problem is that when ever a thread tries to update the text boxes and labels I get the following error: "The calling thread cannot access this object because a different thread owns it." Is it possible to update the co...

Threads in twisted... how to use them properly?

I need to write a simple app that runs two threads: - thread 1: runs at timed periods, let's say every 1 minute - thread 2: just a 'normal' while True loop that does 'stuff' if not the requirement to run at timed interval I would have not looked at twisted at all, but simple sleep(60) is not good enough and construction like: l = task....

Java synchronization question

Hi, I was going through some code snippets looking at the synchronization aspect. I believe locking happens on objects. In the case of java we only have references to objects. Java should use the reference to procure the object and lock it. What happens if the reference happens to be null? I feel this would break. If this were to work t...

.net message loop

Hi everyone. Could anyone help to explain how can I interact with message loop in WPF? I know how to start it using System.Windows.Threading.Dispatcher.Run() Now, I just need a way to call it. I have a while-loop and I whant to process messages in a message loop from it. while (state == DebuggerStaus.Waiting) { ...

Could not find System.Threading after deploying in mscorlib.dll in Microsoft Compact Framework 2.0/3.5.

Hello there, i am facing a problem in windows mobile 6. i have developed an app and i have used Timer class that is present in System.Threading namespace present in mscorlib.dll assembly. the problem is that when i debug it or when i deploy it by creating proper cab file from visual studio 2008 on my device (HTC ELF0300) it runs fine bu...

How can I make a value passed to a function that runs on a separate thread be changed on the original thread?

Hi, I've created an abstract class which implements a method that runs another abstract method on a seperate thread, like this: public abstract class ATest { Thread t; protected String status; public void Start() { ThreadStart ts = new ThreadStart(PerformTest); t = new Thread...

Mapping a thread number to a (non sequential) position in an array

I would like to map a thread_id. This in C/CUDA but it is more an algebraic problem that I am trying to solve. So the mapping I am trying to achieve is along the lines: Threads 0-15: read value array[0] Threads 16-31: read value [3] Threads 32-47: read value [0] Threads 48-63: read value [3] Threads 64-79: read value array[6] Thread...

Spring singleton beans across multiple application contexts

We have a spring application (single-threaded by design). We want to adapt it to be multi-threaded. One Idea was to create a parent thread and spawn different threads which would instantiate their own app context and run in parallel. (Memory and cpu are not a concern as of now). I am not sure how singletons are realized in spring. Does s...

How to efficiently supervise Ruby Threads?

Is the following inefficient? I want to allocate nearly all resources to threads but I'm wondering if in this case this loop will consume a lot of CPU time. Thanks! threads = create_threads #method that returns an Array of Threads loop do alive = false threads.each do |thread| if thread.alive? alive = true end end ...

Updating Swing component from another thread with invokeLater or SwingWorker

Hi guys, I'm developing a small app, which would have Swing GUI. App is doing IO task in another thread, when that thread finishes GUI should be updated acordingly to reflect thread's operation result. Class running in a (worker, non-GUI) has object passed to it in contructor which would be used for updating GUI, so I don't need to put ...