multithreading

Event Handlers synchronization

I have a loop: List<FrameworkElement> list; public void Foo(object sender, PrintPageEventArgs e) { foreach(FrameworkElement fe in list) { fe.LayoutUpdated += FeLayoutUpdated; fe.UpdateLayout(); } if(counter >= lista.Count) e.PageVisual = objectFromClass. // was DoSth() } int counter = 0; void FeLayoutUpdated(object s...

I Need a little help with Python, Tkinter and threading

I have a Python script which uses Tkinter for the GUI. My little script should create a Toplevel widget every X seconds. When I run my code, the first Toplevel widget is created successfully, but when it tries to create a second one the program crashes. What I am doing is using the after method to call the function startCounting every ...

What is the correct use of the ASP.NET Thread Pool?

Hi there, My scenario is this, I have a file that slowly gets populated over the course of an hour or two (mp3, video, etc). As this file is populated many users are connected to the server to receive new data as it is added to the server. At the moment each visitor connects to the server, and an IHttpAsyncHandler allocates a thread fr...

WPF: Running tasks without interfering with Animations Performance

Our group read the widely referenced article http://blog.quantumbitdesigns.com/2008/07/22/wpf-cross-thread-collection-binding-part-4-the-grand-solution/ and wondered if any of you could help with our problem: A team member has a WPF application that has an animation running. The problem is that performing background tasks even on differ...

AutoResetEvent not blocking properly

Hi guys, I have a thread, which creates a variable number of worker threads and distributes tasks between them. This is solved by passing the threads a TaskQueue object, whose implementation you will see below. These worker threads simply iterate over the TaskQueue object they were given, executing each task. private class TaskQueue :...

Threads in Web Application ASP.NET

Hi Guys, I want to use threads in ASP.NET web application. Is it possible to use threads like we use in windows forms application? or what would be the best approach to handle different tasks on the same page which are very time consuming and all the task are inter dependent at the one point. Thanks in advance. ...

Need to know how to check if the inputted string has terminated within a thread-safe logger in C++

I am very new at this and apologise if my question is not clear. I have created a thread safe logger in C++. This logger will be used in a large program & will be called from multiple places. I am using a singleton so there is only one instance of the logger. This logger outputs to a file & to the console. It behaves similar to cout; it...

Does WebView's loadUrl method run on UI thread?

I am wondering how does webview load a particular URL. Does it create a new thread or load the URL in the same thread i.e. UI thread? The reason I am asking this is I am facing some weird wakeup lock issue when I launch an Activity from current Activity (in current Activity's onCreate method) which creates a WebView in it's onCreate meth...

Efficient consumer thread with multiple producers

I am trying to make a producer/consumer thread situation more efficient by skipping expensive event operations if necessary with something like: //cas(variable, compare, set) is atomic compare and swap //queue is already lock free running = false // dd item to queue – producer thread(s) if(cas(running, false, true)) { // We effect...

How can I create Thread safe JSP page

Hi All, I want to create a Thread safe JSP page. It is possible in Servlet by implementing SingleThreadModel interface but I don't know how to do it in JSP page. ...

ColdFusion 9 - My thread is holding onto memory - how can I stop it?

Hi all I have a particular thread that I kick off when by CF9 application starts. It manages a queue and takes items from the queue to process them. If there are no items to take from the queue it will sleep(). This thread could live for weeks, processing and sleeping etc. The problem I am having is that the items I am taking from th...

Should Mutex's lock/unlock functions be "const" ?

Hello, I am maintaining a library that contains a Mutex class. I cannot decide if the lock() and unlock() functions exposed by this class should be const or not. I looked for similar code on the Web, and could find both implementations. First implementation, lock() and unlock() are not const. It means someone who uses the Mutex class i...

Dispatcher vs Multithreading

According to Single-Threaded Application with Long-Running Calculation MSDN example, there is a possibility of creating a responsive GUI in just 1 thread. Thanks to the Dispatcher object, as we can set the Priority of work items. My question is, what sense does it have to do simple tasks (supposing we just have 1 single core cpu) in a ...

Entity Framework and multithreading

Hi, I have a WCF service that processes some messages. I use EntityFramework to retrieve the messages. I add these messages to a ThreadPool queue and then process them. After processing all the messages, I call an update on the Entity Framework to update the status of the messages. Durng this operation, I randomly get the error - "Enti...

NHibernate context sessions, ASP.NET & threading hodgepodge

NHibernate.Context.WebSessionContext, otherwise known as web session context, plays nicely with ASP.NET, but only up to a point. As soon as I spin up a new thread, it is no longer able to retrieve current session from a HttpContext since there's actually no HttpContext for the said thread. How do you make all this play nicely together? ...

Opinions, Suggestions on using a thread in IIS 7 hosted ASP.Net application to avoid a Stack Overflow Exception

In a ASP.Net web application, when you have a stack intensive operation to run, a stackoverflow exception is thrown on IIS when the stack size crosses the IIS set limit of 256K. A regular winform application however has a limit of 1MB. So the exception would not occur when running the same operation in a Winform application. There is no...

COM marshalling problem with modal dialog

I would like to pass a COM object created in the main thread of my C++/MFC8 program to a different thread, and leave all synchronization to COM. Using CoMarshalInterThreadInterfaceInStream works -- until the user opens a modal dialog. While the dialog is open, apparently all marshalling messages are rejected, which I sort of understand b...

How to solve the "Double-Checked Locking is Broken" Declaration in Java?

I want to implement lazy initialization for multithreading in Java. I have some code of the sort: class Foo { private Helper helper = null; public Helper getHelper() { if (helper == null) { Helper h; synchronized(this) { h = helper; if (h == null) ...

pthread_create fails w/ ENOMEM ?

I am seeing pthread_create() fail with rc=12 (ENOMEM), on a 64-bit RHEL machine with 4GB of real memory. The 'top' command shows the process is using 1G of virtual memory when thread creation fails. I am able to create 16 joinable threads, but the 17th and subsequent calls fail with the ENOMEM error (which apparently means memory -or- s...

How can i use Cocoa/CoreText/Quartz for multithreaded drawing

Are there any howtos? What is the best practice here for background thread drawing. Is it okay to store the rectangle data from [NSView drawRect] in a queue and let the background thread take the rectangle and create some bitmap and render the data into the bitmap and then use performSelectorOnMainThread:withObject to draw it? Or can i...