multithreading

C# Application.DoEvnets();

How do I keep my C# form that, lets say is in a for-loop, from locking up? Do I call Application.DoEvents(); before the loop or after? From what I've heard using the DoEvents method will keep my app from locking. ...

synchronized block vs synchronized method?

Can any one tell me the advantage of synchronized method over synchronized block with an example?Thanks. ...

Multithreaded brain : How do you handle it?

Long time ago, i read an article dealing with how women's brain was good at multi task compared to men's one. Now I often think about it. As far as I have noticed, I can do several things at the same time (almost) because of a good scheduling. I was wondering how you guys do, what are some of the hard things you can do at the same time...

Populating drop down list from another thread in ASP.NET

Hi, I have multiple drop down lists on a page. They all contain list of countries. So in the background I am getting countries from database and caching them. I would like to populate those drop down lists from another thread. I am also using AJAX controls so I wanted that it all happens at the same time. And also after a user selects a ...

Unhandled ThreadAbortException occuring - sometimes

Hello! I have a dialog that has to process large quantaties of data (the procedure is quite time consuming - first the ODBC fill takes its time, then the data processing kicks in) and the result is that the Form becomes unresponsive. This is not a problem really, it is enough to just open a "loading screen" in a new thread to notify the...

send(), returns Winsock Error 10038

Problem: Call to send(), returns Winsock Error 10038 against socket handle Illustration: acceptedSocket = accept (server, (sockaddr *)&sin, &len); accept(), returns 0 A new thread, is created for each connection send(), (in thread function) returns 10038 Illustration: - in thread function //omitted SOCKET RemoteSocket = (SOC...

How do synchronized static methods work in Java?

If I have a util class with static methods that will call hibernate functions to accomplish basic data access. I am wondering if making the method synchronized is the right approach to ensure thread-safety. I want this to prevent access of info to the same DB instance. However, I'm now sure if the following code are preventing getObject...

If ThreadPool is full, how to make Action.BeginInvoke spawn a non threadpool thread

In .net 3.5 trying to ThreadPool.QueueUserWorkItem(a=> {Work()}); when the ThreadPool has no available threads caused BeginInvoke lock up. void Work() { Action executor = () = { DoSomething(); }; IAsyncResult result = executor.BeginInvoke(null, null); using (WaitHandle hWait = result.AsyncWaitHandle) { if (hWait.Wait...

accessing member variable of boost thread object

I'm using an object to start boost thread and it has some public member variables which I modify in the thread (in the () operator). How can I access the object's member variables from outside the thread? I tried using a mutex (defined in the object's class) that is locked both in the operator() of the object and from outside, but it do...

How to parallelize small pure function?

I have D2 program that, in its current form, is single threaded, and calls the same pure function about 10 to 100 times in an inner loop for each iteration of the outer loop of this program. There is no data dependency among the calls, i.e. no call uses the result from any other call. Overall, this function is called millions of times,...

Posix Threads in c++

How to implement posix threads in linux c++.The smme program when saved as ".c and run using c compiler is ok. but in c++ it is giving error .. I think i made mistake when compiling is there any tag to be included like "-lpthread" for c++ Can someone pls send a valid code...? Actually this is my code int cooperbussman :: startlis...

How to keep process from exiting when a pthread exits?

I am writing a server program in C wherein every time a client connects, I create a new pthread to handle the client's requests. When all of the threads exit, however, then my program exits, as though a call to exit() has been made. This is a problem - how can I overcome it? Lets say the server is running, and 2 clients connect. Once t...

How to use IGlobalInterfaceTable to pass an interface pointer?

Without: MFC ATL Question: What are the steps involved, to use IGlobalInterfaceTable, when passing a particular interface pointer to several threads using CreateThread? ...

Using BackgroundWorker or Threading for high performance

Hi all, How can use BackgroundWorker or Threading for my code. I update TreeView (Winforms) and I call WCF service. Any suggestions please. Kind regards. Thanks in advance AdministradorUILogging.TrazarDebug("PanelArbolFicheros. tslGuardarArbol_Click") Dim listaFichero As New List(Of Fichero) Windows.Forms.Cursor.Current = Cursors.Wa...

ThreadPool Best Practices, Correctness

Hey everyone. I've been working on some code for a while that would spawn threads when needed, but decided a simpler and more effective solution would be to create a thread pool. It's implemented with a queue I made that has conditional waits on queuing and dequeuing. The only reason I'm posting this, is because I'm getting some weird er...

How long should a thread sleep when the event pattern doesn't apply?

In the main loop of a worker thread that has to poll to know if there's work to do, I let it sleep in order to not busy-wait. How do I determine a good length for sleeping? E. g. if I wake up every millisecond, it's probably useless to sleep at all. If I wake up every ten minutes, it might make the app look unresponsive (depending on wha...

Windbg stack trace issue

Hello everyone, I am debugging a crash dump of managed code, when using !threads to show all threads here, a couple of threads has Exception field value with various exceptions. My question is how to identify which exception is the root exception which causes process crash in a quick way? Any ideas why so many threads are associated wi...

Is this a safe version of double-checked locking?

Slightly modified version of canonical broken double-checked locking from Wikipedia: class Foo { private Helper helper = null; public Helper getHelper() { if (helper == null) { synchronized(this) { if (helper == null) { // Create new Helper instance and store reference on ...

If Quartz Scheduler dies, how do I stop the child Java processes that it started?

I'm currently using Quartz Scheduler as a replacement for Cron on our Windows 2003 Server Box. I have two specific Jobs that needed to be started in a new VM, so I'm using the ProcessBuilder object in Java 5 to get my "Process" object. The problem I'm running into is when our Quartz Scheduler JVM stops, the 2 jobs in separate JVM's kee...

Reset IIS on multiple servers at once instead of looping through

I am trying to reset IIS on a set of servers all at one time instead of looping through and resetting each one individually, but I can't seem to figure out how to do it. Could someone please give me an example? Thank you I am using System.Diagnostics With m_Process.StartInfo .FileName = strFileName ...