multithreading

Waiting for Event Triggering in Silverlight Unit Tests

I am using the Silverlight Unit Testing Framework to test some View Manager classes. Some tests require the PropertyChanged events to be fired. I'm currently using a combination of EnqueueConditional and WaitHandles Example 1 [TestMethod] [Asynchronous] [Timeout(1000)] public void TestNotificationExample() { var manager = new User...

Async function - callback using object owned by main thread

In my .NET application built with WPF and C# I call an async function using AsyncMethodCaller. In the callback I'd like to update some data in the GUI, but I'm not allowed to as this is owned by the main thread. How to I do it? Invoke an update on the main thread? How? Pass an object (e.g. ViewModel) as state to the callback and upda...

How to make the main thread wait for the other threads to complete in ThreadPoolExecutor

Hi, I am using the ThreadPoolExecutor to implement threading in my Java Application. I have a XML which I need to parse and add each node of it to a thread to execute the completion. My implementation is like this: parse_tp is a threadpool object created & ParseQuotesXML is the class with the run method. try { ...

thread reaches end but isn't removed

I create a bunch of threads to do some processing: new Thread("upd-" + id){ @Override public void run(){ try{ doSomething(); } catch (Throwable e){ LOG.error("error", e); } finally{ LOG.debug("thread death"); } } }.start(); I know i should be using a threadPool but i need to ...

Calling a Lua function from another thread

In my sample application, I have basically two threads. The main thread contains a Lua engine (which is not thread-safe) and registers some C++ functions into this engine. However, one of these functions takes too long to perform (since it downloads some file over the internet) and I want the Lua engine to continue doing other stuff wit...

C++/CLI efficient multithreaded circular buffer

I have four threads in a C++/CLI GUI I'm developing: Collects raw data The GUI itself A background processing thread which takes chunks of raw data and produces useful information Acts as a controller which joins the other three threads I've got the raw data collector working and posting results to the controller, but the next step i...

How to run a timer in an separate thread?

I have a loop like below for(int i = 0; i < 10; i++) { // some long time processing } I want to create a timer, which would check if one processing runs more than 5 minutes. If one processing runs more than 5 minutes, it would stop current processing then start another processing. Is it possible to make another thread to monitor...

Should events be raised in new Threads to not block current work?

Hello, I'm currently designing an assembly that will be used by third parties. One of the classes has a long process of TCP connections and it informs about its process using events. For example ''# Do stuff that takes some time RaiseEvent CompletedFirstPartEvent() ''# Do stuff that takes some time RaiseEvent CompletedSecondPartEvent()...

In there something similar to Java's Thread.yield() in Python? Does that even make sense?

I want to tell my Python threads to yield, and so avoid hogging the CPU unnecessarily. In Java, you could do that using the Thread.yield() function. I don't think there is something similar in Python, so I have been using time.sleep(t) where t = 0.00001. For t=0 there seems to be no effect. I think that maybe there is something I am not...

Java: How to use Thread.join

I'm new to threads. How can I get t.join to work, whereby the thread calling it waits until t is done executing? This code would just freeze the program, because the thread is waiting for itself to die, right? public static void main(String[] args) throws InterruptedException { Thread t0 = new Thready(); t0.start(); } @Override pu...

C# TraceSource class in multithreaded application

msdn: "Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe." it contains only instance methods. How should I use it in a way that all activity gets recorder by TextWriterTraceListener to a text file. Is one static member which all threads use (by cal...

Invoking a method from a class

Hi all, I'm developing a serial port communication application. I've written a class. In serial port's DataReceived event, I need to invoke a method to do some string operations. I want to make these operations in another thread. But since my application is not a windows from application (it's a class only), it does not have the Invoke...

way to implement IPC

what is the preferred way to implement IPC over windows ? i know of several like : named pipe, shared memory, semaphors ? , maybe COM (though i'm not sure how)... i wanted to know what's considered the most robust,fast,least error prone and easy to maintain/understand. ...

Main thread hangs indefinitely while waiting for NSOperationQueue operations to cancel [Only on Device!]

I have an NSOperationQueue on my main thread running a set of NSOperations (max concurrent set to 1) that I want to be able to cancel at any time. When I press a button I tell the queue to cancel all operations and wait until finished. This should hang the main thread until the operation queue is empty, however it is hanging my main thre...

thread synchronization

let's say i have a blocking method , let's call in Block(). as i don't want my main thread to block i might create a worker thread, that instead will call Block. however, i have another condition. i want the call to block to return in 5 seconds top, otherwise, i want to let the main thread know the call to Block failed and to exit the...

Dialog doesn't display properly with .Show but don't want to block on .ShowDialog while multithreading in C#

I have a program that needs to connect to a server to gather some data. I start a new thread and have it perform the connection sequence. In this sequence it will continue to try to connect until it successfully does so. The code is as follows for the connect sequence: // Code for InitializeConnection // Our address to our Authenticati...

Timer access Class Field

Hi all Is there any possible way to access the field - str in the Class Program and the variable num - in the main function? class Program { string str = "This is a string"; static void Main(string[] args) { int num = 100; Debug.WriteLine(Thread.CurrentThread.ManagedThreadId); var timer = new System....

A question on python GIL

Hi friends, Does the presence of python GIL imply that in python multi threading the same operation is not so different from repeating it in a single thread?. For example, If I need to upload two files, what is the advantage of doing them in two threads instead of uploading them one after another?. I tried a big math operation in bot...

Is opening too many threads in an application bad?

I have a C# winform application. it has many forms with different functionalities. These forms wrap to a WCF service. for example form1 calls serviceMethod1 continuously and updates the results form2 calls serviceMethod2 continuously and updates the results The calls are made in a different thread per each form, but this is ending up...

Thread.Start() vs BackgroundWorker

what is the difference between create thread using thread.start and using background worker ? ...