multithreading

How do I persist an object between threads without using httpcontext.items?

I've got an object that handles in memory caching for my data access layer (DAL) and I need to persist it between threads. From what I've read the preferred method is to use httpcontext.item with code like so: Shared Property DALList() As Dictionary(Of String, DAL) Get If Not Web.HttpContext.Current.Items.Contain...

Threading problem in WPF

Hi all, I'm getting this Exception System.InvalidOperationException was unhandled by user code Message="The calling thread cannot access this object because a different thread owns it." whenever I run the following code public partial class MainScreen : Window { Timer trm; public MainScreen() ...

Why is my file-loading thread not parallelized with the main thread?

My program does file loading and memcpy'ing in the background while the screen is meant to be updated interactively. The idea is to have async loading of files the program will soon need so that they are ready to be used when the main thread needs them. However, the loads/copies don't seem to happen in parallel with the main thread. The ...

What's the use of the SyncRoot pattern?

I'm reading a c# book that describes the SyncRoot pattern. It shows void doThis() { lock(this){ ... } } void doThat() { lock(this){ ... } } and compares to the SyncRoot pattern: object syncRoot = new object(); void doThis() { lock(syncRoot ){ ... } } void doThat() { lock(syncRoot){ ... } } However, I don't really...

c# closing progam from Main contructor

after alot of head scathing i think I have made some progress. I am not 100% sure but Can you exit an application before the constructor is finsihed and the main form loaded? constuctor { thread t = new thread(open loading screen); } I do the exact same thing with a exit screen using a variable between the main for and another one. and...

Do .NET Timers Run Asynchronously?

I have a messaging aspect of my application using Jabber-net (an XMPP library.) What I would like to do, if for some reason the connection to the Server is ended, is keep trying to connect every minute or so. If I start a Timer to wait for a period of time before the next attempt, does that timer run asynchronously and the resulting Ti...

Opening a WPF Window in another Thread from a Windows Forms App

OK, I should start this off by saying I'm not sure this is necessarily the right way to deal with this but... Basically I have created a Window in WPF for displaying notifications in my application (a bit like Outlook New Mail notification). I would like to try and show this Window in it's own thread (it might do some work in the future...

Waiting for pthread_create to finish without using pthread_join

I want to halt one thread till another thread has finished initializing without using pthread_join. I tried using a join but it leads to a deadlock due to some asynchronous inter-thread communication system that we have. Right now, I'm using a (custom) lock to achieve this. In Thread 1: lock_OfflineWorker.Lock() if (pthread_create(&tid...

Python/wxPython: Doing work continuously in the background

I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes. When the user starts a simulation, and defines an initial state, I want the program to render the simulation con...

Threading:Lock on generic dictionary

I have a generic dictionary in a multithreaded application; to implement a lock i created a property. static object myLock=new object(); Dictionary<key,SomeRef> dict=new Dictionary<key,SomeRef>(); public Dictionary<key,SomeRef> MyDict{ get{ lock(myLock){ return dict; } } } Now if i write CODE#1 ...

XPathDocument Threading Question

I have a web application where I am trying to cache an XPathDocument. The XPathDocument is created as follows. XPathDocument xdoc = new XPathDocument(new StringReader(ruleXml)); Then I want to just cache this xdoc and retrieve it for each request. And then I plan to call XPathNavigator nav = xdoc.CreateNavigator(); on...

Multiprocessing or Multithreading?

I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes. When the user starts a simulation, and defines an initial state, I want the program to render the simulation con...

My thread does not appear to have been created... any idea why?

In my windows application i have a usercontrol, which in turn host few other usercontrols. Just before the end of the main user control's constructor, i try to create a thread... but it does not appear to be created: mainUserControl() { var t=new Thread(ThreadJob); t.IsBackground=true; t.Start(); } private void ThreadJob() ...

ASP.NET threading + design question

I have an application that performs a write to a database each time a page is requested. This db write is not time critical, so for performance reasons, I have the page queuing the object using MSMQ. Of course, I have to have something to read the queue and process requests, so I wrote a class that looks similar to this: public class Qu...

ASP.NET Performance: Worker Threads and I/O Threads

Duplicate of: What’s the difference between a worker thread and an I/O thread? What is the difference between an I/O thread and an Worker thread in IIS/ASP.NET? How do these concepts affect the design of an ASP.NET app? ...

polling joystick C#

i have an application that records a date/time when the space bar is pressed unfortunately, the window doesn't always have focus, for various reasons. eg virus checker popup, itunes update, windows update, etc so what i though would be a cool idea is to use a joystick button, then regardless of which window has focus, i can always detec...

Please confirm that this XMPP code is not threadsafe

I'm reading the source code to the Smack api and the the method XMPPConnection#disconnect looks like this: public void disconnect(Presence unavailablePresence) { // If not connected, ignore this request. if (packetReader == null || packetWriter == null) { return; } shutdown(unavailablePresence); if (roster ...

How run sqlite in background on the iPhone?

I wonder how run sqlite querys in the background as suggested in http://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa This is my try: - (void) run:(NSString *)sql { NSArray *data = [NSArray arrayWithObjects: sql, [self returnItemClass], nil]; NSInvocationOpera...

Why does the Main Run Loop put an Execution Thread to sleep if there is no event occuring?

I dont understand why Threads have to "sleep" if there is no event in the Application Run Loop. Does this save energy, or memory, or what else? When there comes in an event from an source input, then it would wake up that Thread again to handle this event. After that, it would sleep again, for the case that there is no more event in the...

Using an HTTPContext across threads

User hits page spawn.aspx which then spawns a half-dozen threads, rendering pages all using ((System.Web.IHttpHandler)instance).ProcessRequest(reference to spawn's HTTPContext); Don't worry about the fact that ASP.Net is seemingly sending the user 7 responses for 1 request, that part is handled and only one response gets sent. The ...