Hello,
this morning I saw some strange code from one of my coworkers. In an winforms application the whole Mainform was given into a thread as reference.
He did this to invoke methods from the Form. Nothing to interact with the UI, just plain calculation methods.
I am already sure this is not a best-practice but I wonder something. If I...
New to this website, so let me know if I'm not posting in an accepted manner.
I've frequently coded something along the lines of the sample below(with stuff like Dispose ommited for clarity. ). My question is, are the volatiles needed as shown? Or does the ManualResetEvent.Set have an implicit memory barrier as I've read Thread.Start...
Sorry if I am asking same question again but want to verify!
I have two processes P1 and P2.
P1 is a writer (Producer).
P2 is a reader (Consumer).
There is some shared memory or a file that P1 writes to and as soon as P1 writes, P2 should be notified for reading.
Now as per my understanding pseudocode for P1 should be
Open shared ...
Given the following code, can you figure out what caused "You input 7 characters" showed up 3 times especially the
last time?
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <semaphore.h>
void *thread_function(void *arg);
sem_t bin_sem;
#define WORK_SIZE 1024
char work_area[W...
On my laptop with Intel Pentium dual-core processor T2370 (Acer Extensa) I ran a simple multithreading speedup test. I am using Linux. The code is pasted below. While I was expecting a speedup of 2-3 times, I was surprised to see a slowdown by a factor of 2. I tried the same with gcc optimization levels -O0 ... -O3, but everytime I got t...
Hello
I have a python program with 2 threads ( let's name them 'source' and
'destination' ). Source thread sometimes post a message to destination
thread with some arguments. Than destination thread picks a message it
must call a corresponding function with aruments saved in message.
This task can be solved multiple ways. The easy one ...
I have an application that hosts several WCF services. I have created a custom ServiceAuthorizationManager that is working perfectly. I inspect a few elements on the OperationContext.IncomingMessageHeaders to get a username and password. This was to overcome some limitations in our environment that wouldnt allow us to use what was bui...
I'm writing a windows service that runs a variable length activity at intervals (a database scan and update). I need this task to run frequently, but the code to handle isn't safe to run multiple times concurrently.
How can I most simply set up a timer to run the task every 30 seconds while never overlapping executions? (I'm assuming Sy...
In multithreaded .NET programming, what are the decision criteria for using ThreadPool.QueueUserWorkItem versus starting my own thread via new Thread() and Thread.Start()?
In a server app (let's say, an ASP.NET app or a WCF service) I think the ThreadPool is always there and available. What about in a client app, like a WinForms or...
I'm having some problems threading my pyGTK application. I give the thread some time to complete its task, if there is a problem I just continue anyway but warn the user. However once I continue, this thread stops until gtk.main_quit is called. This is confusing me.
The relevant code:
class MTP_Connection(threading.Thread):
def ...
So I am trying to create a check that tries to connect to the WWW. when it fails it needs to then retry several times before the application gives up and quits. Each time it retries the user is propted with an UIAlertView with the options to Retry or Cancel.
So here is the problem.
I have a chain of actions in an NSOperationQueue, all...
I have an application which has an asynchronous operation built into it that loops over a large number of items and performs lengthy calculations on each item, as this occurs certain conditions will cause the application to pop up a modal dialog for user input. Interestingly, I noticed while running this today that in one application ins...
There are many methods you shouldn't call if you are not on the AWT event thread. These are generally methods that manipulate the UI in some way.
Is this the case with Component's getGraphicsConfiguration(...)? It is only a getter but it appears to cause a deadlock if the event thread is waiting on the thread calling this method.
Whi...
I was looking through a Findbugs report on my code base and one of the patterns that was triggered was for an empty synchronzied block (i.e. synchronized (var) {}). The documentation says:
Empty synchronized blocks are far more
subtle and hard to use correctly than
most people recognize, and empty
synchronized blocks are almost...
In asp.net 2.0 , c#.
Is it possible to start a thread from a page, for example when a asp:button is clicked and from another page, check if that thread has exited?
Reason: We have a page that starts a long server-side script when a button is clicked. However, since we don't want to wait the ending of the script on that page, we thought...
On my remoting server I wish to display a toast when a message is posted from a client. When a message is received, I try:
public void Log( string message )
{
new Toast( message ).Show();
}
However, the toasts lock up during creation due to what I assume is a threading issue. I do not, however, know how to resolve ...
is there any documentation on exactly how expensive it is:
if (x.IsInvokeRequired)
{
beginInvoke . . . .
}
If you have a case where 90% pct of the time is on a background thread (and thus required) is it worth it?
If you have a case where 90% pct of the time is on a UI thread (and thus not required) is it worth it?
Any metrics a...
TVirtualTreeview is pretty much awesome, but many times when I close an window referenced by a DLL in my project that has a TVirtualTreeview in it I get the NTWaitForMultipleObjects error.
The problem is somewhere deep in TVirtualTreeview and other guys in the office have tried lots of stuff to fix it, I was just wondering if anyone e...
I wonder if I could read or write shared int value without locking on mips cpu (especially Amazon or Danube). What I mean is if such a read or write are atomic (other thread can't interrupt them). To be clear - I don't want to prevent the race between threads, but I care if int value itself is not corrupted.
Assuming that the compiler a...
I've implemented a system in C# that uses the Microsoft Message Queue (System.Messaging) for communication between related processes. Essentially, a number of Sender services generate messages to put in the queue and a number of Receiver processes watch the queues and grab those messages when they arrive.
I've just been told that there...