multithreading

Is this a good way to implement the Asynchronous Programming Model?

I've been on a tear lately trying to learn everything I can about .Net Multithreading. (Getting better at it, but still feel like there's lots to learn). Right now I'm focusing on the APM (Asynchronous Programming Model) which is commonly known as this: //non async method public int DoSomeWork(int arg) { //do something and return res...

Queue message processing with Multithreading

Hi, I have to design multithreaded module for a problem. And problem is, I have queue, there is a one thread which is putting messages in the message queue, and there are two thread say A and B, thread A process the even message (0,2,4..) and thread B processes the odd message(1,3,5..). I came up with two solution, first one is using tw...

What's the equivalent C# 'Thread.Join()' in Cocoa?

I'm making an iPhone app using threads. I was used C# for a while, there was a method Thread.Join() which blocks current thread for specific thread completes execution. What's the equivalent in Cocoa for it? Or Alternatives? ---edit--- PS. I'm using NSThread. ---edit--- I'm finding a method like 'waitForThreadExit' which blocks calle...

Profiling of Python threads

Hello, I am trying to figure out how to measure the performance of several python threads in my application. I currently have several tasks that are executing on different threads based on user input and I would like to measure the execution time, maybe even memory consumption of each of the threads. I have tried to use cProfile (on eac...

How do you efficiently debug reference count problems in shared memory?

Assume you have a reference counted object in shared memory. The reference count represents the number of processes using the object, and processes are responsible for incrementing and decrementing the count via atomic instructions, so the reference count itself is in shared memory as well (it could be a field of the object, or the objec...

Java: Deleting a GUI object from within the GUI

Hey Guys Can you help me out here? A really simple problem but I just can't get what the solution is! I am coding a listener application that runs on its own thread & listens on a ServerSocket for incoming connections. When a connection arrives, a new 'Message' object is created on a new thread and passed the incoming text data "messa...

Regarding Semaphore Class in .Net

Dear Gurus I had a requirement to allocate the resource to number of threads so i used semaphores to handle all this then i realized that semaphore are used in case of Interprocess locking of resources. I googled and found some implementation of In-Process Semaphore and used that class but it has some weird bugs. Now my question is Sh...

Threads and waiting

I have a thread that gathers a list of URLs from a website and updates the UI as it's doing so. That works fine. But, I need the Main thread to wait until the links have been gathered. I tried to do a join, but this locks up the UI. Here is my example. As you can see at the moment the foreach loop gets called at the same time as the thre...

TExternalThread, what the heck is it? "Cannot terminate externally created thread" when terminating a thread-based timer :/

This happens half of the time when closing my application in which I have placed a TLMDHiTimer on my form in design time, Enabled set to true. In my OnFormClose event, I call MyLMDHiTimer.Enabled := false. When this is called, I sometimes (about half of the time) get this exception. I debugged and stepped into the call and found that it...

How unique is ManagedThreadID?

MSDN says: Gets a unique identifier for the current managed thread. In what context does "unique" apply? Is this unique per process? per AppDomain? per Machine? per .NET runtime? (if I have both MS.NET and Mono running ) ...

.Net System Wide Flag to determine if Application/Thread is Running

I'm developing a long running process that hosts remoting objects. Due to design restrictions, I cannot use a Windows Service so the process is a background Forms application. I also cannot use WPF because we are restricted to .Net 2.0. In any case, since there is no guarantee that the background process is running, I want to be able to ...

Multiple Threads

I post a lot here regarding multithreading, and the great stackoverflow community have helped me alot in understand multithreading. All the examples I have seen online only deal with one thread. My application is a scraper for an insurance company (family company ... all free of charge). Anyway, the user is able to select how many thre...

Profiling .Net thread contention

Is there any tool available to profile .Net Thread contention. I have added performance counter for threads for a windows Service which is running slow. It shows around 150 thread contentions. I would like to profile what area of the code is responsible for so much of Thread contentions. Is there any tool available which can point me int...

Thread vs. Adapter for backgroud tasks - which one to prefer and why?

As a total noob to android programming I was advised to make use of adapters and handlers in order to update a textview periodically rather than thread/sleep. However, I wonder why! Any suggestions? ...

Stopping a thread in python

I am creating a thread in my Python app with thread.start_new_thread. How do I stop it if it hasn't finished in three seconds time? ...

What does MethodImplOptions.Synchronized do?

Is the code below [MethodImpl(MethodImplOptions.Synchronized)] public void Method() { MethodImpl(); } same as public void Method() { lock(this) { MethodImpl(); } } ...

Controlling FPU behavior in an OpenMP program?

I have a large C++ program that modifies the FPU control word (using _controlfp()). It unmasks some FPU exceptions and installs a SEHTranslator to produce typed C++ exceptions. I am using VC++ 9.0. I would like to use OpenMP (v.2.0) to parallelize some of our computational loops. I've already successfully applied it to one, but the n...

Strange Message about threads in C#

Hello, I have a program that I run and in the middle I get this message: Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\Documents and Settings\Lena G\My Documents\SchoolStuff\IR Information\Home Work\FianlProject\finalProject\finalProject\bin\Debug\finalProject.vshost.exe'. Additional Information: The...

Get calling thread

Is there a way to get the information of the main thread (the application thread) from a second thread? My problem is that I have to set the currentprincipal in the main thread, but the authentication is done in another thread because it's a long and complex task, but when I set the currentPrincipal in the second thread, the main thread...

When myThread.Start(...) is called, do we have the assurance that the thread is started?

When myThread.Start(...) is called, do we have the assurance that the thread is started? The MSDN documentation isn't really specific about that. It says that the status of is changed to Running. I am asking because I've seen a couple of times the following code. It creates a thread, starts it and then loop until the status become Runn...