multithreading

How do Threads work in Objects

hey guys, I'm totally inexperienced in terms of threads, so here's my question: How do threads work within an instance of an object, in particular, I'm working on a Windows Service. So, my Service is basically an instance of an Object right? So, say I have a System.Timers.Timer in my Service, and that fires an ElapsedEventHandler ever...

Converse of java FileDescriptor .sync() for *reading* files

Reading the javadoc on FileDesciptor's .sync() method, it is apparent that sync() is primarily concerned with committing any modified buffers back to the underlying storage. I.e., making sure that anything that your program has output will actually make it to the disk (or socket or what-have-you, but my question pertains mainly to disks)...

powershell / runspace in a thread

Hello ! I'm running the following code : RunspaceConfiguration config = RunspaceConfiguration.Create(); PSSnapInException warning; config.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out warning); if (warning != null) throw warning; Runspace thisRunspace = RunspaceFactory.CreateRunspace(config); thisRunspa...

Canceling Worker threads in winforms

I've got two list boxes, one a master, the other a child. When the index changes on the master, the child listbox gets filled appropriately with records relating to the master. My problem is coming up when one master takes a long time to get all the records and before it has completed getting the records, a user clicks a different mast...

Locking on several methods only if a thread is in a certain method

I have a class (simplified example) like : public class SomeCollection : ICloneable { public void Add(Item item) { /* ... */ } public void Remove(Item item) { /* ... */ } public Item Get(Key key) { /* ... */ } /* ... */ public object Clone() { /* ... */ } } I need that when a thread enters Clone() no other ...

Threaded debugging in C# and vs2008

Hi all, I have a pretty serious multithreaded debugging problem. I have some kind of timing issue when interacting with a serial device, and I need to track it down. I have three threads: The main thread for UI updates. The user can either change one parameter of the device, or many all at once by choosing a preset. The status chec...

C# WM6 Compact Framework Cross Thread Communication Problem

Hi all, I'm having a problem updating a control on my ui from a thread created using ThreadPool.QueueUserWorkItem Inside this thread i am calling addControlToPanel(li); As shown here private delegate void addControlToPanelDelegate(ListItem li); private void addControlToPanel(ListItem li) { if (panel1.InvokeRequired) { ...

Is this method of converting an asynchronous method to a synchronous one correct?

I've got a method implemented using the Event-based Asynchronous method pattern. I also want to offer a synchronous version of that method, but don't want to re-write it (because the method involves a call to WCF from Silverlight, the Async version has to be the primary method). I've come up with the following generic method to convert ...

Stopping a thread

In a java application,when the user hits download,establishing the remote connection and downloading the content from remote is done in a separate thread and a dialog is popped up in the screen to show the download progress. Now a cancel command has been added to the dialog inorder to provide the user with an option of cancelling the dow...

Looking for some UI thread and working thread tutorials

Hello everyone, My working environment is VSTS 2008 + C# + .Net 3.5. I want to learn the differences between UI thread and worker thread, and any other types of thread (i.e. non-UI thread is the same as worker thread)? I also want to learn the restrictions of what we can do on each type of threads and best practices to avoid any issues....

How to kill a specific thread from an array of threads

Hi. I am creating an array of threads based on the number of records in a database. Each thread then polls an ipaddress and then sleeps for a time and then repolls again. I periodically check the database for any change in the number of hosts. If there are more hosts I start another thread. If there are less hosts I need to kill the spec...

How to stop exution of a method call in WCF after a transaction timout

I have created a test service with a method that contains a very long loop. I was hoping that when a timeout transaction occurs, the method execution will flush, but it doesn't. The client gets a timeout, but the processing continues on the server. Is there way to stop it? Without changing the method code? Here is the example: in the ...

Why is this COM interop event not raised whilst running under an STA thread?

Can somebody please explain why the event "OnNewMail" is not raised when using an STA thread in the code below? The program attempts to use the Redemption library to intercept incoming outlook mails. class Program { [STAThread()] // When this line is deleted the application works static void Main(string[] args) { ...

C# creating as many instances of a class as there are processors

I have a GUI C# application that has a single button Start/Stop. Originally this GUI was creating a single instance of a class that queries a database and performs some actions if there are results and gets a single "task" at a time from the database. I was then asked to try to utilize all the computing power on some of the 8 core syst...

multiple lock in same function

I have a function thats the main bottleneck of my application, because its doing heavy string comparisions against a global list shared among the threads. My question is basicly this: Is it bad practive to lock the list ( called List gList ) multiple times in 1 function. For then to lock it again later ( Basicly locking when doing the l...

Java synchronization not working as (I) expected

Hi, programmer mates. I was testing java threading capabilities with a very simple code (or at least it seemed simple). I have this class Account: public class Account { protected double balance; public synchronized void withdraw(double value) { this.balance = this.balance - value; } public synchronized void deposit(double value...

Controlling iPhone App Flow During Table View Animations

In my application I would like to be able to wait until table view animations (deleting table view rows) were complete before executing part of my application. I was wondering if there would be any way to wait or pause my application until the these animations were complete. Thanks. ...

Multi-threading with iPhone SDK

I'm using a separate NSAutoReleasePool for my thread NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self bulkyFunction]; // time consuming op [self performSelectorOnMainThread: @selector(doneAll) withObject:nil waitUntilDone:NO]; [pool release]; and I call a function (bulkyFunction) that allocates two strings. current...

WCF Self Hosting Performance

I am in the process of writing an enterprise-level application utilizing WCF and NetTCP services. I chose NetTCP initially out of curiosity, but later determined it to be the best option for me since I can have services that are called that take 5+ hours to return results due to the amount of data crunching involved. The way I currently...

garbage collection of an object that holds reference to alive threads

In Java: I have an object that holds references to 2 daemon threads. I am considering the corner case where it is not deinitialized, so I can determine whether I need a finalizer. The function for detinitializing stops the threads. I could go ahead and just add a finalizer but I am curious: a) Can the object get garbage collected while...