Is there an attribute to mark the class or method to be thread safe in .NET?
In .NET how can I know if a class or method is thread safe or not? Is it by default not thread safe? ...
In .NET how can I know if a class or method is thread safe or not? Is it by default not thread safe? ...
Hi! I have just stumbled across the Backgroundworker object, and it seems like the tool I'm looking for to make my GUI responding while performing calculations. I am writing IO plugins for ArcGIS. I am doing some data processing outside ArcGIS, which works fine using the backgroundworker. But when I'm inserting the data into ArcGIS, th...
I have a block of code like this that runs as a child thread: if(someVar == 1){ doSomeStuff; _exit(0) } else execvp(*(temp->_arguments), temp->_arguments); printf("I'm done\n"); When I run the program with someVar == 1, I understand that the _exit(0) call kills my thread. However, when it's set to 0, why doesn't the program contin...
I have a local class with a method used to build a list of strings and I'm finding that when I hit this method (in a for loop of 1000 times) often it's not returning the amount I request. I have a global variable: string[] cachedKeys A parameter passed to the method: int requestedNumberToGet The method looks similar to this: List...
I really don't know why the if statement below is not executing: if (s == "/quit") { System.out.println("quitted"); } Below is the whole class. It is probably a really stupid logic problem but I have been pulling my hair out over here not being able to figure this out. Thanks for looking :) class TextParser extends Thread { ...
I have just written my own logging framework (very lightweight, no need for a big logging framework). It consists of an interface ILogger and a number of classes implementing that interface. The one I have a question about is TGUILogger which takes a TStrings as the logging target and synchronizes the logging with the main thread so that...
Looking for a good site or book that explains windows threads, preferably for a beginner. Maybe has a example program to run, etc.... ...
I want to launch a process from Java, read its output, and get its return code. But while it's executing, I want to be able to cancel it. I start out by launching the process: ProcessBuilder pb = new ProcessBuilder(args); pb.redirectErrorStream(true); Process proc = pb.start(); If I call proc.waitFor(), I can't do anything until the p...
If I am using EventWaitHandle (or AutoResetEvent, ManualResetEvent) to synchronise between threads then do I need to call the Close() or Dispose() methods on that event handle when I am done with it? EventWaitHandle inherits from WaitHandle, which implements IDisposable. And FxCop complains if I don't implement IDisposable on any class ...
Many projects I work on have poor threading implementations and I am the sucker who has to track these down. Is there an accepted best way to handle threading. My code is always waiting for an event that never fires. I'm kinda thinking like a design pattern or something. ...
I've got some code that screen scrapes a website (for illustrative purposes only!) public System.Drawing.Image GetDilbert() { var dilbertUrl = new Uri(@"http://dilbert.com"); var request = WebRequest.CreateDefault(dilbertUrl); string html; using (var webResponse = request.GetResponse()) using (var receiveStream = webResponse...
I'm having a strange problem. I have the following code: dbg("condwait: timeout = %d, %d\n", abs_timeout->tv_sec, abs_timeout->tv_nsec); ret = pthread_cond_timedwait( &q->q_cond, &q->q_mtx, abs_timeout ); if (ret == ETIMEDOUT) { dbg("cond timed out\n"); return -ETIMEDOUT; } dbg calls gettimeofd...
Given the documentation at http://docs.python.org/library/threading.html which states for Thread.run(): You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwar...
Hi, The following Function is executing in its own thread: private void doSendData() { try { //writeToFile(); // just a temporary location of a call InetAddress serverAddr = InetAddress.getByName(serverAddress); serverAddr.wait(60000); //Log.d("TCP", "C: Connecting..."); Socket socket ...
What is the simplest way to update an label from another thread? My problem: I have a winform(thread1), from that I'm starting another thread(thread2). While thread2 is processing some files I would like to update a label on the winform, with status from thread2. How can I do that? ...
I'm writing a class library that will offer some asynchronous processing, and want to try and avoid running into threading issues later on down the line. So I'm after any suggestions people can make to avoid running into issues later on, and instead start with a good design. Some of the situations that I can see that might cause problem...
I think that nunit isn't function properly when threading code is involved: Here's the sample code: public class multiply { public Thread myThread; public int Counter { get; private set; } public string name { get; private set; } private Object thisLock = new Object(); ...
See this code: public class multiply { public Thread myThread; public int Counter { get; private set; } public string name { get; private set; } public void RunConsolePrint() { lock(this) { RunLockCode("lock"); } } private vo...
I'm not asking for anyone to do this homework for me, but I bring it up because it's a very good practical introduction to C# and threading, but at the same time I feel it's perhaps a little too simple. Is this really the best way to teach threading? what key threading concepts are "lost" in this exercize, what would new programmers u...
I like to use objects which sync itself using a private object which is locked when the property is changed. Is there any generic way to achieve this? My code looks always like this for each property (with one locker object) private Object locker = new Object(); private int x; public int X { get {return x;} set{ ...