multithreading

Explain the code: c# locking feature and threads

I used this pattern in a few projects, (this snipped of code is from CodeCampServer), I understand what it does, but I'm really interesting in an explanation about this pattern. Specifically: Why is the double check of _dependenciesRegistered. Why to use lock (Lock){}. Thanks. public class DependencyRegistrarModule : IHttpModule { ...

Queues And Wait Handles in C#

I've had the following code in my application for some years and have never seen an issue from it. while ((PendingOrders.Count > 0) || (WaitHandle.WaitAny(CommandEventArr) != 1)) { lock (PendingOrders) { if (PendingOrders.Count > 0) { fbo = PendingOrders.Dequeue(); } else { ...

What free tools or strategies can help debug a multi-threading corruption bug?

I have a client server application with multi-threading. The server side is failing with a std::list getting corrupted resulting in a SEGV. I suspect that there is some kind of cross thread timing issue going on where the two threads are updating the std::list at the same time and causing it to be corrupted. Please suggest free tools ...

For loop index out of range ArgumentOutOfRangeException when multithreading

I'm getting some strange behavior... when I iterate over the dummyText List in the ThreadTest method I get an index out of range exception (ArgumentOutOfRangeException), but if I remove the threads and I just print out the text, then everything works fine. This is my main method: public static Object sync = new Object(); static void Ma...

how to write silverlight threading function in another file or project

I am using three tier architecture.I have SilverlightUI and UIController two projects.SilverlightUI contains only UI pages and controls while UIController contains all proxies of WCF services. Now I have created threads to update my controls dynamically and to do processing parallel.AS the requirement I want to define all functionality o...

Why my async call does not work?

Hi, I am trying to understand what is IAsyncresult good and therefore I wrote this code. The problem is it behaves as I called "MetodaAsync" normal way. While debugging, the program stops here until the method completed. Any help appreciated, thank you. using System; using System.Collections.Generic; using System.Linq; using System.Text...

Is there a way to use .Net 4.0 System.Threading.Tasks class in .Net 3.5 or .Net3.0 versions?

Hi, I get to understand the .Net 4.0 provides a better approach on multi-threading with tasks. Is there a way that it is possible to do the same approach in .Net 3.5 or .Net 3.0. Thanks, Priya.R ...

new thread run() not called

Hi, I'm writing a qt browser plugin. I have a worker class that inherits QThread. The weird thing that is happening to me is, the run() is called when i call a thread.start() in my machine. But when i run the same code in another machine, the code crashes when the thread.start() is invoked. Im totally confused. Any help would be apprec...

I am confused -- Will this code always work?

Hello, I have written this piece of code public class Test{ public static void main(String[] args) { List<Integer> list = new ArrayList<Integer>(); for(int i = 1;i<= 4;i++){ new Thread(new TestTask(i, list)).start(); } while(list.size() != 4){ // this while loop required so that all threads complete t...

How to find a particular dll is threadsafe or not ? Ant API/tool for this?

For example, i downloaded Gecko 1.9.1 SDK. It contains js3250.dll. How i can be sure that this dll is thread-safe? Advance Thanks -Parimal Das ...

python iterators and thread-safety

I have a class which is being operated on by two functions. One function creates a list of widgets and writes it into the class: def updateWidgets(self): widgets = self.generateWidgetList() self.widgets = widgets the other function deals with the widgets in some way: def workOnWidgets(self): for widget in self.widgets: ...

how to find the active thread count?

Hi, i have a c# program which calls into a c++ library. The c# programs process has a high thread count 50 - 60. Most seem to be created in c++ and i supect most are suspended/waiting. How do i find how many of these threads are active at a given point in time? thanks ...

What's the memory overhead for a single windows threads?

Is it 1 Mb of stack per thread? Or is that just CLR threads? I want to know the memory over head of native windows threads (c++) and CLR threads as view via Task Manager. Thanks ...

Neat way of calling InvokeRequired and Invoke

I seem to remember seeing some neat way of calling InvokeRequired and Invoke to avoid repeating too much code in every event handler but I can't remember what that was. So does anyone know a neat way of writing that code? Preferably for VB.Net 2005. ...

fast thread ordering algorithm without atomic CAS

I am looking for an approach that will let me assign ordinal numbers 0..(N-1) to N O/S threads, such that the threads are in numeric order. That is, the thread that gets will have a lower O/S thread ID than the thread with ordinal 1. In order to carry this out, the threads communicate via a shared memory space. The memory ordering m...

Is ReaderWriterLockSlim.EnterUpgradeableReadLock() essentially the same as Monitor.Enter()?

So I have a situation where I may have many, many reads and only the occasional write to a resource shared between multiple threads. A long time ago I read about ReaderWriterLock, and have read about ReaderWriterGate which attempts to mitigate the issue where many writes coming in trump reads and hurt performance. However, now I've bec...

Java Micro Edition - HTTP sending/receiving using Threads and Delegates (how to update UI)

Hi there, I'm making a shopping list app which basically uploads your shopping list to a php file and also downloads all the updates anyone else has made to the list. I'm using record stores w/ record enumeration and an item object Basically i want to be able to send off all the elements in the record store to the php file using a thr...

OGNL thread safety

I'm going to reuse OGNL library out of Struts2 scope. I have rather large set of formulas, that is why I would like to precompile all of them: Ognl.parseExpression(expressionString); But I'm not sure if precompiled expression can be used in multi-thread environment. Does anybody knows if it can be used? ...

What design pattern to use for a threaded queue

I have a very complex system (100+ threads) which need to send email without blocking. My solution to the problem was to implement a class called EmailQueueSender which is started at the beginning of execution and has a ScheduledExecutorService which looks at an internal queue every 500ms and if size()>0 it empties it. While this is goi...

invoking PopViewController on Main Thread from Secondary Thread

Hi Friends, I am doing my functionality in a secondary thread and once I get the result, I call the function that pops my ViewController in the main thread. But I get the following error: void WebThreadLockFromAnyThread(), 0x5c6dec0: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be ...