Click here to Skip to main content
15,903,822 members
Home / Discussions / C#
   

C#

 
QuestionWinforms custom property fails to reload - continued from QA Pin
Midi_Mick18-Jan-17 3:53
professionalMidi_Mick18-Jan-17 3:53 
AnswerRe: Winforms custom property fails to reload - continued from QA Pin
Gerry Schmitz18-Jan-17 4:47
mveGerry Schmitz18-Jan-17 4:47 
GeneralRe: Winforms custom property fails to reload - continued from QA Pin
Midi_Mick18-Jan-17 4:54
professionalMidi_Mick18-Jan-17 4:54 
GeneralRe: Winforms custom property fails to reload - continued from QA Pin
Gerry Schmitz18-Jan-17 5:19
mveGerry Schmitz18-Jan-17 5:19 
GeneralRe: Winforms custom property fails to reload - continued from QA Pin
Midi_Mick18-Jan-17 5:34
professionalMidi_Mick18-Jan-17 5:34 
QuestionRe: Winforms custom property fails to reload - continued from QA. A new clue. Pin
Midi_Mick18-Jan-17 4:48
professionalMidi_Mick18-Jan-17 4:48 
QuestionWhen is it safe to use Monitor (lock) with Task? Pin
Bernhard Hiller18-Jan-17 2:34
Bernhard Hiller18-Jan-17 2:34 
AnswerRe: When is it safe to use Monitor (lock) with Task? Pin
Pete O'Hanlon18-Jan-17 3:25
mvePete O'Hanlon18-Jan-17 3:25 
Well, you could supply a custom TaskScheduler implementation that creates a new Thread every time but that seems to be a bit overkill. Alternatively, you can use the Interlocked class to lock access to whatever needs to be done on a one at a time basis.
C#
private int locked = 0;

private void SomeMethod()
{
  try
  {
    // In the code that you want to sync on.
    if (Interlocked.CompareExchange(ref locked, 1, 0) != 0)
    {
      return;
    }

    // Do whatever you need to do here...
  }
  finally
  {
    Interlocked.Exchange(ref locked, 0);
  }
}

This space for rent

GeneralRe: When is it safe to use Monitor (lock) with Task? Pin
Bernhard Hiller18-Jan-17 21:05
Bernhard Hiller18-Jan-17 21:05 
AnswerRe: When is it safe to use Monitor (lock) with Task? Pin
Richard Deeming18-Jan-17 8:11
mveRichard Deeming18-Jan-17 8:11 
GeneralRe: When is it safe to use Monitor (lock) with Task? Pin
Bernhard Hiller18-Jan-17 21:11
Bernhard Hiller18-Jan-17 21:11 
GeneralRe: When is it safe to use Monitor (lock) with Task? Pin
Pete O'Hanlon18-Jan-17 21:15
mvePete O'Hanlon18-Jan-17 21:15 
QuestionGroup of Checkboxes Pin
eejaynic17-Jan-17 11:41
eejaynic17-Jan-17 11:41 
AnswerRe: Group of Checkboxes Pin
Gerry Schmitz17-Jan-17 13:02
mveGerry Schmitz17-Jan-17 13:02 
GeneralRe: Group of Checkboxes Pin
eejaynic17-Jan-17 14:11
eejaynic17-Jan-17 14:11 
GeneralRe: Group of Checkboxes Pin
Gerry Schmitz17-Jan-17 14:53
mveGerry Schmitz17-Jan-17 14:53 
AnswerRe: Group of Checkboxes Pin
Richard Deeming18-Jan-17 2:04
mveRichard Deeming18-Jan-17 2:04 
GeneralRe: Group of Checkboxes Pin
eejaynic18-Jan-17 9:03
eejaynic18-Jan-17 9:03 
QuestionCommunicating with unmanaged DLL Pin
Member 1041441717-Jan-17 2:43
Member 1041441717-Jan-17 2:43 
AnswerRe: Communicating with unmanaged DLL Pin
Midi_Mick17-Jan-17 3:19
professionalMidi_Mick17-Jan-17 3:19 
GeneralRe: Communicating with unmanaged DLL Pin
Member 1041441717-Jan-17 4:13
Member 1041441717-Jan-17 4:13 
AnswerRe: Communicating with unmanaged DLL Pin
Bernhard Hiller17-Jan-17 23:26
Bernhard Hiller17-Jan-17 23:26 
QuestionRe: Communicating with unmanaged DLL Pin
Member 1390693510-Jul-18 22:01
Member 1390693510-Jul-18 22:01 
QuestionGlade errors after launching debug Pin
Sascha Manns16-Jan-17 23:18
professionalSascha Manns16-Jan-17 23:18 
AnswerRe: Glade errors after launching debug [Solved] Pin
Sascha Manns17-Jan-17 5:41
professionalSascha Manns17-Jan-17 5:41 

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.