Click here to Skip to main content
15,914,165 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generic Collection class question Pin
akyriako7822-Nov-05 12:30
akyriako7822-Nov-05 12:30 
GeneralRe: Generic Collection class question Pin
Christian Graus22-Nov-05 12:39
protectorChristian Graus22-Nov-05 12:39 
AnswerRe: Generic Collection class question Pin
smh123-Nov-05 8:58
smh123-Nov-05 8:58 
QuestionXmlValidatingReader problem with xs:date Pin
IsaacB22-Nov-05 6:51
IsaacB22-Nov-05 6:51 
QuestionDynamically Add Textboxes to datagrid Pin
tadhg8822-Nov-05 6:36
tadhg8822-Nov-05 6:36 
AnswerRe: Dynamically Add Textboxes to datagrid Pin
Stanciu Vlad22-Nov-05 9:08
Stanciu Vlad22-Nov-05 9:08 
QuestionProblem with Mutex in multithreading Application Pin
Alexandr Sergeevich Ilyin22-Nov-05 6:16
Alexandr Sergeevich Ilyin22-Nov-05 6:16 
AnswerRe: Problem with Mutex in multithreading Application Pin
whizzs22-Nov-05 8:57
whizzs22-Nov-05 8:57 
Try switching your Thread.Sleep(100) with your mutex.Release(). Since Thread.Sleep() is a static method you can't be sure which thread is sleeping if you have released the synchronization

Also, I don't think your implementation is correct. Since your threads do not own the Mutex I do not believe they will be synchronized. You should have both threads call the same function so the Mutex can protect the resource.

public class Test
{
  protected Mutex mutex;
  public Test()
  {
    mutex = new Mutex(false);
    Thread A = new Thread(new ThreadStart(TF));
    Thread B = new Thread(new ThreadStart(TF));
    A.Start();
    B.Start();
  }
  void TF()
  {
    while(true)
    {
      mutex.WaitOne();
      Console.Write("do some work {0}", Thread.CurrentThread.Name);
      Thread.Sleep(100);
      mutex.ReleaseMutex();
    }
  }
}


and since your synchronization is inside an infinite while loop I don't know what will happen as far as sharing process time
-- modified at 16:11 Tuesday 22nd November, 2005
GeneralRe: Problem with Mutex in multithreading Application Pin
Alexandr Sergeevich Ilyin22-Nov-05 17:24
Alexandr Sergeevich Ilyin22-Nov-05 17:24 
GeneralRe: Problem with Mutex in multithreading Application Pin
S. Senthil Kumar22-Nov-05 19:34
S. Senthil Kumar22-Nov-05 19:34 
AnswerRe: Problem with Mutex in multithreading Application Pin
S. Senthil Kumar22-Nov-05 19:36
S. Senthil Kumar22-Nov-05 19:36 
GeneralRe: Problem with Mutex in multithreading Application Pin
Alexandr Sergeevich Ilyin22-Nov-05 19:53
Alexandr Sergeevich Ilyin22-Nov-05 19:53 
AnswerRe: Problem with Mutex in multithreading Application Pin
mcljava29-Nov-05 12:57
mcljava29-Nov-05 12:57 
QuestionHow do i get directx to play a video, without opening a new window? Pin
Anthony Mushrow22-Nov-05 6:01
professionalAnthony Mushrow22-Nov-05 6:01 
AnswerRe: How do i get directx to play a video, without opening a new window? Pin
leppie22-Nov-05 19:00
leppie22-Nov-05 19:00 
QuestionCapture console output Pin
Kash22-Nov-05 5:42
Kash22-Nov-05 5:42 
AnswerRe: Capture console output Pin
S. Senthil Kumar22-Nov-05 5:57
S. Senthil Kumar22-Nov-05 5:57 
GeneralRe: Capture console output Pin
Kash22-Nov-05 23:40
Kash22-Nov-05 23:40 
QuestionHow to playback file wave by tapi Pin
sharapova22-Nov-05 4:51
sharapova22-Nov-05 4:51 
QuestionHash Code calculation Pin
J4amieC22-Nov-05 4:20
J4amieC22-Nov-05 4:20 
AnswerRe: Hash Code calculation Pin
Stanciu Vlad22-Nov-05 6:08
Stanciu Vlad22-Nov-05 6:08 
GeneralRe: Hash Code calculation Pin
J4amieC22-Nov-05 6:23
J4amieC22-Nov-05 6:23 
GeneralRe: Hash Code calculation Pin
Stanciu Vlad22-Nov-05 7:40
Stanciu Vlad22-Nov-05 7:40 
GeneralRe: Hash Code calculation Pin
Leslie Sanford22-Nov-05 9:57
Leslie Sanford22-Nov-05 9:57 
Questionapplication version (major and minor) c# winform Pin
fady_sayegh22-Nov-05 2:34
fady_sayegh22-Nov-05 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.