multithreading

STA, MTA and OLE nightmare

I have to include a .NET application into another .NET application as a plugin. The plugin interface requires me to inherit from a template form. The form is then attached in a MDI when the plugin is loaded. Everything is working so far, but whenever I register for drag and drop events, set the autocomplete mode for a combobox or at var...

AsyncCallback for a thread on compact framework

I need to implement threading to improve load time in a compact framework app. I want to fire off a background thread to do some calls to an external API, while the main thread caches some forms. When the background thread is done, I need to fire off two more threads to populate a data cache. I need the background thread to be able to e...

Multi-threaded file write enqueueing

So I have a static class that is supposed to be used as a log file manager, capable of adding "messages" (strings) to a Queue object, and that will push messages out to a file. Trouble is, many different threads should be enqueueing, and that the writer needs to be async as well. Currently when I insert into the queue, I'm also checkin...

What is java's equivalent of ManualResetEvent?

What is java's equivalent of ManualResetEvent? ...

Do I have to pthread_join each thread I create?

From pthread_join() man page: When a joinable thread terminates, its memory resources (thread descriptor and stack) are not deallocated until thread performs pthread_join on it. Therefore, pthread_join must be called once for each joinable thread created to avoid memory leaks. Does it mean I need to join each thread I create to pre...

Knowing when a JFrame is fully drawn

I have a program that creates a JFrame and makes it visible. Is there anyway to know when the JFrame is fully drawn and visible? Right now a hacky "wait and pray" method is being used. Thanks for the help! ...

Using NSThreads in Cocoa?

I wanted to know how to use threads in Cocoa. I'm new to this so I don't understand the documentation that well. The Top half of the code is for timing and the bottom half is for the date. Can anyone show me how to use a single thread and how to use 2 threads to handle both operations. NSDateFormatter *timeFormatter = [[[NSDateFormatte...

Are there any benefits of suspending a thread over making it wait?

I was going through a legacy code and found that the code uses SuspendThread Function to suspend the execution of a worker thread. Whenever the worker thread needs to process a request, the calling thread resumes this worker thread. Once the task is done the thread suspends itself. I don’t know why it was done this way. According to me...

C#, Event Handlers and Threading

I'm writing a little chat app, and I have this event handler: void o_Typing(object sender, EventArgs e) { MessageBox.Show("Fired!"); this.Text = "Fired!"; } o_Typing is a method in a class derived from TabPage. Basically, I want each conversation to have it's own tab. The event handlers are fired by my Chat object, which is r...

Threadsafe publishing of java object structure ?

Assuming that I have the following code: final Catalog catalog = createCatalog(); for (int i = 0; i< 100; i++{ new Thread(new CatalogWorker(catalog)).start(); } "Catalog" is an object structure, and the method createCatalog() and the "Catalog" object structure has not been written with concurrency in mind. There are several non-f...

Closing a thread with select() system call statement?

Hi all, I have a thread to monitor serial port using select system call, the run function of the thread is as follows: void <ProtocolClass>::run() { int fd = mPort->GetFileDescriptor(); fd_set readfs; int maxfd=fd+1; int res; struct timeval Timeout; Timeout.tv_usec=0; Timeout.tv_sec=3; //BYTE ack_mess...

How to avoid flooding a message queue?

I'm working on an application that is divided in a thin client and a server part, communicating over TCP. We frequently let the server make asynchronous calls (notifications) to the client to report state changes. This avoids that the server loses too much time waiting for an acknowledgement of the client. More importantly, it avoids dea...

Timer events do not fire in a thread when using Server.MapPath

Hi, I have the following scenario with ASP.NET 2.0. I have declared an atlas:timer as follows in my .aspx page: <atlas:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="3000" Enabled="false"> </atlas:Timer> I also have a button on a form which when clicked launches a new System.Threading.Thr...

Pausing a method for set # of milliseconds

Hi everybody! I need to do a sort of "timeout" or pause in my method for 10 seconds (10000 milliseconds), but I'm not sure if the following would work as i do not have multi-threading. Thread.Sleep(10000); I will try to use that current code, but I would appreciate if someone could explain the best and correct way of doing this, espec...

OpenThread() Returns NULL Win32

I feel like there is an obvious answer to this, but it's been eluding me. I've got some legacy code in C++ here that breaks when it tries to call OpenThread(). I'm running it in Visual C++ 2008 Express Edition. The program first gets the ThreadID of the calling thread, and attempts to open it, like so: ThreadId threadId = IsThreaded...

Multi java processes by jvm ?

Hi, If I want to run several processes in the same jvm without synchronizing (I don't care about multi things running at the same time... I only want to avoid re-instanciating the jvm), what is the best solution ? Starting one thread and joining to wait until it dies, and then creates another thread to do another task ? ...

100% responsive UI in WPF

Hello, I have a WPF application that uses a component that sends a bitmap to my application as they become available, I receive those bitmaps in a delegate I pass to this component. I created a new thread for this process and it works very well, the bitmaps comes as MemoryStream and I just create the BitmapSource object from this stream...

IIS and Threads

We are starting to write more and more code for an ASP.Net web application uses a new thread to complete long running tasks. I can find no solid documentation that give any useful guide to any limitations of restrictions of using threads within IIS (6). Any advice to this end would be appreciated - specifically the following: What (i...

Why do multiple threads eat my memory

I have a Windows C++ application that holds a std::hash_set containing abount 5 Million entries each with 32 Bytes. If i create the hash_set in a separate (of many) threads it uses > 1 GB according to ProcessExplorer. I see this when i free the list. If i create it in the main thread it ueses 200 MB. This phenomenon only applies to the 3...

Possible to force Delphi threadvar Memory to be Freed?

I have been chasing down what appears to be a memory leak in a DLL built in Delphi 2007 for Win32. The memory for the threadvar variables is not freed if the threads still exist when the DLL is unloaded (there are no active calls into the DLL when it is unloaded). The question: Is there some way to cause Delphi to free memory associat...