Archive

Posts Tagged ‘Threads’

Debugging Locks and Deadlocks

February 23rd, 2009 Elze 2 comments

Today I found myself in a problem I never guessed I would get into, deadlocks. A deadlock is a situation where one lock is waiting for another lock to clear. But the other lock can’t be cleared until the piece of code that’s currently is waiting for the lock to clear is run. More about Threads and Locks can be found here. And with a little bit of googling ;-)

Problem with deadlocks is the seem quite hard to find, and when found to solve. At the moment my program runs in a deadlock I press the Pauze button in Visual Studio, problem: Visual Studio stops at the position where the program is in the main thread. When using WPF in .NET Micro Framework this isn’t very usefull.

But I managed to find the piece of code that blocks but that doesn’t help a lot eather becouse you can’t see what piece of code currently holds the lock.

Read more…

Categories: Tips-n-Tricks Tags: , ,

WPF, Delegates and Threads

November 8th, 2008 Elze 2 comments

Introduction:
When I started programming for the .NET Micro Framework one of the things that where a bit difficult to grab was how to update WPF UI elements (Like a text control) from a thread.

It has all to do with thread safety. Threads run (semi) simultainus and so there is the change that you access the same variable at the same time. When you have you’re own variables that you want make "Thread-Safe" you can use the lock statement (MSDN). When you’re developing for WPF you can use the Dispatcher and DispatcherTimer to  "Thread-Safe" access UI controls.

Read more…