Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
AnswerRe: Windows Installer. Pin
Curtis Schlak.21-Nov-05 17:05
Curtis Schlak.21-Nov-05 17:05 
Questionhow to add module in c#.net Pin
sarayumadhavan21-Nov-05 1:07
sarayumadhavan21-Nov-05 1:07 
AnswerRe: how to add module in c#.net Pin
S. Senthil Kumar21-Nov-05 4:51
S. Senthil Kumar21-Nov-05 4:51 
QuestionShould you add and remove event handlers willy-nilly? Pin
Gizz21-Nov-05 0:32
Gizz21-Nov-05 0:32 
AnswerRe: Should you add and remove event handlers willy-nilly? Pin
Robert Rohde21-Nov-05 1:06
Robert Rohde21-Nov-05 1:06 
GeneralRe: Should you add and remove event handlers willy-nilly? Pin
Gizz21-Nov-05 3:01
Gizz21-Nov-05 3:01 
GeneralRe: Should you add and remove event handlers willy-nilly? Pin
Robert Rohde21-Nov-05 7:48
Robert Rohde21-Nov-05 7:48 
AnswerRe: Should you add and remove event handlers willy-nilly? Pin
Charlie Williams21-Nov-05 7:32
Charlie Williams21-Nov-05 7:32 
A race condition can occur when an event is fired incorrectly. It has nothing to do with how handlers are subscribed and unsubscribed. If you fire like this:

public event EventHandler HandleThis;

void OnHandleThis(EventArgs e)
{
   if (HandleThis != null)
   {
      HandleThis(this, e);
   }
}


A separate thread could unsubscribe the last handler from the HandleThis event between the time you check for null and the time you actually fire it.

You can eliminate the race condition by using a temporary variable.

void OnHandleThis(EventArgs e)
{
   EventHandler handler = HandleThis;
 
   if (handler != null)
   {
      handler(this, e);
   }
}


This page[^] mentions the problem and the solution. It's for WinFX, not v1.1, but it's the same concept.

I'm not sure why your supplier thinks you should handle events you're not interested in, but he's wrong.

Charlie

if(!curlies){ return; }
AnswerRe: Should you add and remove event handlers willy-nilly? Pin
Leslie Sanford21-Nov-05 9:10
Leslie Sanford21-Nov-05 9:10 
QuestionHow to get embedded .jpeg from excel worksheet? Pin
Andrew Muliar21-Nov-05 0:30
Andrew Muliar21-Nov-05 0:30 
QuestionHow to minimize/maximize a borderless form from the taskbar Pin
tprashanth21-Nov-05 0:21
tprashanth21-Nov-05 0:21 
QuestionParse a word doc and update contents to database Pin
ranjithib120-Nov-05 22:14
ranjithib120-Nov-05 22:14 
AnswerRe: How to use C# to call a traditional unmanaged C++ DLL which has many functions with pointer parameters? Pin
Stanciu Vlad20-Nov-05 21:50
Stanciu Vlad20-Nov-05 21:50 
QuestionHow to use C# to call a traditional unmanaged C++ DLL which has many functions with pointer parameters? Pin
tsung-yu20-Nov-05 20:48
tsung-yu20-Nov-05 20:48 
AnswerRe: How to use C# to call a traditional unmanaged C++ DLL which has many functions with pointer parameters? Pin
RobstaHendricks23-Nov-09 5:53
RobstaHendricks23-Nov-09 5:53 
Question,F1 help in Windows App Pin
Stephen McAllister20-Nov-05 19:53
Stephen McAllister20-Nov-05 19:53 
Questionhow to download or upload a file using C# Pin
v.k.s20-Nov-05 17:09
v.k.s20-Nov-05 17:09 
AnswerRe: how to download or upload a file using C# Pin
Christian Graus20-Nov-05 17:15
protectorChristian Graus20-Nov-05 17:15 
QuestionGetChildAtPoint which is out of screen Pin
tsunsau71720-Nov-05 17:06
tsunsau71720-Nov-05 17:06 
QuestionC# inheritance Pin
ppp00120-Nov-05 16:53
ppp00120-Nov-05 16:53 
AnswerRe: C# inheritance Pin
Christian Graus20-Nov-05 17:10
protectorChristian Graus20-Nov-05 17:10 
AnswerRe: C# inheritance Pin
S. Senthil Kumar20-Nov-05 18:50
S. Senthil Kumar20-Nov-05 18:50 
QuestionAdding button to Menu Bar in Office 2003 Web Components Pin
ykoon20-Nov-05 16:25
ykoon20-Nov-05 16:25 
Questionquestion on Impersonation Pin
ekynox20-Nov-05 15:16
ekynox20-Nov-05 15:16 
AnswerRe: question on Impersonation Pin
ekynox20-Nov-05 18:09
ekynox20-Nov-05 18:09 

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.