multithreading

Why is my Form so shy?

EDIT 2 Okay, based on the advice on the answers below I eliminated my thread approach and now my program looks like this: program.cs static void Main(){ Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FrmWWCShell FrmWWCShell = null; var splash = new FrmSplash(); splash.SplashFormInitialized +...

Help translation PYTHON to VB.NET

I am coding an application in VB.NET that sends sms. Would you please post PYTHON->VB.NET translation of this code and/or guidelines? Thanks in advance!!! import threading class MessageThread(threading.Thread): def __init__(self,msg,no): threading.Thread.__init__(self) self.msg = msg # text message self.no = no ...

Running a threaded class as a deamon

I am writing a multi-threaded solution in Java to connect two systems, A & B. System A is completly serial, not threaded, and will supply data to send to system B. System B accepts data from multiple sources asynchronously all at the same time. I am using ThreadPoolExecutor to manage the threads. I am using a static singleton instanc...

How to do asynchronous inter thread communication on platform with pthreads

For example on windows there is MsgWaitForMultipleObjects that lets you asynchronously wait for windows messages, socket events, asynchronous io (IOCompletionRoutine), AND mutex handles. On Unix you have select/poll that gives you everything except possibility to break out when some pthread_mutex is unlocked. The story: I have applica...

Do multithreading and autorelease pools work together in Cocoa?

I would like to send an object back to the main thread from worker thread. However do auto-release pools work between threads? Is there anything wrong with the following code: -(void)mainThreadReceiveResult:(id)response { [response retain]; /* Do some stuff with response */ [response release]; } -(void)workerThreadDoWork { N...

Circular lock-free buffer

I'm in the process of designing a system which connects to one or more stream of data feeds and do some analysis on the data than trigger events based on the result. In a typical multi-threaded producer/consumer setup, i will have multiple producer threads putting data into a queue, and multiple consumer threads reading the data, and the...

Asynchronous implmentation help please

Hi, I'm trying to develop a class that supports an asynchronus method invocation. This is what I've come up with so far, however, I'm not sure if its the 'right way' of doing it. I only want the async method to be executed once, it doesn't have to support multiple executions so I didn't use the AsyncOperationManager class. Can someone...

concurrent variable access in c

I have a fairly specific question about concurrent programming in C. I have done a fair bit of research on this but have seen several conflicting answers, so I'm hoping for some clarification. I have a program that's something like the following (sorry for the longish code block): typedef struct { pthread_mutex_t mutex; /* some sh...

Threading in Java

I am trying to have my main thread spawn off a new thread and, after some time, raise the interrupt flag. When it does so, the spawned thread should see that flag and terminate itself. The main thread looks something like this: final Thread t = new Thread() { @Override public void run() { f(); } }; t.start(); try { t.join(time);...

Relationship between threads,appdomains,worker process

What is the exact relationship, in IIS7 and ASP.Net, between : IIS Worker processes Threads AppDomains Applications incoming requests I'm hoping for an answer in a format similar to : "Each IIS worker process hosts many appdomains which each spawn a single thread in response to each request...." etc. , and any nuances mentioned. Th...

crossthread operations error

if (listBox1.InvokeRequired) { listBox = new StringBuilder(this.listBox1.Text); } This is the code in c# which when executed produces an invalid cross thread operation error for listBox1 which is a listbox in my form. Could u guys please tell me why?? I am using the invokeRequired method too and am not ch...

Invocation exception using AutoResetEvent

Hello, C# 2005 I am using a background worker to process some login information. However, the background worker has to stop and wait for 2 events to happen. Once these have finished the background worker can complete its job. They are callbacks that will call the Set() method of the AutoResetEvent. So I am using AutoResetEvent to set ...

Threads sychronized

Hi I create two thread first thread to call application and second thread for read file that result from calling aplication on the first thread. Call application work fine but read the file doesnt work. can you help me plz? here is my code /* * To change this template, choose Tools | Templates * and open the template in the editor. *...

Synchronizing two threads...

I have two threads and I want the second thread to wait until first thread finishes. How can I accomplish this? This my code: public class NewClass1 implements Runnable { // in main CallMatlab c = new CallMatlab(); CUI m = new CUI(); Thread t1 = new Thread(c); t1.start(); Thread t2 = new Thread(m); try { ...

When is it safe to destroy a pthread barrier?

If I have an initialised pthread_barrier_t, when is it safe to destroy it? Is the following example safe? pthread_barrier_t barrier; ... int rc = pthread_barrier_wait(b); if (rc != PTHREAD_BARRIER_SERIAL_THREAD && rc != 0){ perror("pthread_barrier_wait"); exit(1); } if (id == 0){ if(pthread_barrier_destroy(&(threads[t_root].info...

asp.net :to call join method on more than one thread objects?

i have a listoddata and a list of thread in main thread .i am passing each element data of list to corresponding thread.want to main thread to wait untill all of thread are executed. for (int i = 0; i < listOfThread.Count; i++) { listOfThread[i].Join(); } // code after all of thread completes its...

Does this multithreaded program perform better than the non-multithreaded one?

A colleague of mine asked me to write a homework for him. Although this wasn’t too ethical I did it, I plead guilty. This is how the problem goes: Write a program in C where the sequence 12 + 22 + ... + n2 is calculated. Assume that n is multiple of p and p is the number of threads. This is what I wrote: #include <pthread.h> #include <...

Printing Daemonic Thread Exceptions in Python

Python does not print traceback messages from exceptions raised in daemon threads. For example, this code creates a daemonic thread and raises an exception in the new thread: def error_raiser(): raise Exception import threading thread = threading.Thread(target=error_raiser) thread.daemon = True thread.start() but does not print ...

Signal to a calling thread that a resource is already in use.

Question slightly in the abstract... We have a situation where we have a struct that can be accessed by 2 or 3 threads concurrently. We wish to signal to a thread that tries to modify the struct if it is already being modified. e.g. The code at the moment: thread0: struct->modify(var SomeNewState) thread1: struct->modify(var SomeNewS...

can i easily write a program to make use of Intel's Quad core or i7 chip if only 1 thread is used?

I wonder if in my program I have only 1 thread, can I write it so that the Quad core or i7 can actually make use of the different cores? Usually when i write programs on a Quad core computer, the CPU usage will only go to about 25%, and the work seems to be divided among the 4 cores, as the Task Manager shows. (the programs i wrote usu...