Linked Questions

16 votes
5 answers
7k views

I am working on a multi threaded WindowsPhone8 app that has critical sections within async methods. Does anyone know of a way to properly use semaphores / mutexes in C# where you are using nested ...
Michael Sabin's user avatar
3 votes
3 answers
1k views

I have this C# code: public class Locking { private int Value1; private int Value2; private object lockValue = new Object(); public int GetInt1(int value1, int value2) { ...
Jürgen Steinblock's user avatar
4 votes
2 answers
8k views

Extra question Does SemaphoreSlim(1, 1) still ensures that I have the correct output 1000000, even if task1 and task2 run on 2 different cores? Original question Considering the following code snippet,...
Tomingsun's user avatar
  • 310
2 votes
3 answers
3k views

Let's say I have a form with two buttons (button1 and button2) and a resource object (r). The resource has its own locking and unlocking code to handle concurrency. The resource could be modified by ...
Frank Weindel's user avatar
7 votes
1 answer
2k views

Semaphores are a multi-threading locking mechanism that ensure that only a limited number of threads are running on a given resource. Mutexes are a special case where that limited number is one. ...
John's user avatar
  • 7,119
0 votes
2 answers
417 views

I have a method StartProcess(). I want this method to throw an exception if the same method is called by another thread at the same time or by the same initial thread before EndProcess() is called. I ...
Kacey Ezerioha's user avatar
-2 votes
1 answer
482 views

I might be overthinking this, but I'm not sure I understand how locking works when dealing with await/async. Given the following, after each await a different thread can return to execute the next bit ...
creativergk's user avatar
-1 votes
1 answer
188 views

Given a scenario where there's a function that should only be executed by one thread at any given time, and the rest just return (since a specific state is already being worked on), what's the best ...
Dennis19901's user avatar
2 votes
2 answers
87 views

My backend application takes byte arrays that represent image data and applies certain transformations to it, like changing the resolution and such, and then stores this modified data to disk. During ...
Allu's user avatar
  • 71
0 votes
2 answers
105 views

I began to study lock and immediately a question arose. It docs.microsoft says here: The lock statement acquires the mutual-exclusion lock for a given object, executes a statement block, and then ...
user avatar