Re: c# Thread problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



<cty0000@xxxxxxxxx> schrieb im Newsbeitrag
news:1183545253.022824.26220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 7 4 , 6 31 , "Jon Skeet [C# MVP]" <s...@xxxxxxxxx> wrote:
On Jul 4, 10:27 am, cty0...@xxxxxxxxx wrote:

while (true)
{
Thread.Sleep(100);
lock (queueLock)
{
while (GuiMsgQueue.Count == 0)
Monitor.Wait(queueLock);

gMsg = GuiMsgQueue.Dequeue();
The following line should be outside of the lock block. The lock should only
spawn the deqeueing, not what is done with the deqeued object after.

update(gMsg);
}
}
}


I'm not sure, if this causes the deadlock. Since deadlocks can only occur
with atleast two lock-objects, there must something else go on. Maybe the
call on update blocks, waiting for the Mainthread, while this is trying to
achieve a lock on qeueLock. This would produce a deadlock.

Christof


.



Relevant Pages

  • Re: c# Thread problem
    ... common source of deadlock in .NET code. ... update label and lock for push a data to QUEUE ... Pull the call to update out of the lock block. ...
    (microsoft.public.dotnet.languages.csharp)
  • "lock" keyword and exceptions
    ... There is one method that modifies them. ... My quetion is, if an exception is thrown within the lock block, will the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [patch] Real-Time Preemption, -RT-2.6.10-rc1-mm3-V0.7.18
    ... I got the attached deadlock report. ... Nov 8 04:19:32 eran kernel: PREEMPT ... Nov 8 04:19:32 eran kernel: kjournald:1445 BUG: lock held at task exit time! ...
    (Linux-Kernel)
  • Re: deadlock when reading most currently inserted records
    ... Our solution is to use ROWLOCK hints on all INSERT, UPDATE, and DELETE ... > select obtaining a shared lock, then the insert obtaining an IX lock at ... Printing deadlock information ... > SPID: 53, ECID: 0, Not Blocking ...
    (microsoft.public.sqlserver.programming)
  • Re: [RFC, PATCH] locks: remove posix deadlock detection
    ... Thread A of task B takes lock 1 ... We currently declare deadlock at this point (unless the deadlock detection ... locked region is put to sleep by attempting to lock another ...
    (Linux-Kernel)