Click here to Skip to main content
15,889,527 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# accessing Excel Pin
led mike10-Apr-07 7:39
led mike10-Apr-07 7:39 
QuestionFileWatcher Pin
LCI10-Apr-07 5:32
LCI10-Apr-07 5:32 
AnswerRe: FileWatcher Pin
vineas10-Apr-07 5:48
vineas10-Apr-07 5:48 
QuestionUser Control - comments for public properties in form designer Pin
peterchen10-Apr-07 5:13
peterchen10-Apr-07 5:13 
AnswerRe: User Control - comments for public properties in form designer Pin
Martin#10-Apr-07 5:40
Martin#10-Apr-07 5:40 
QuestionListview and remove or disallow duplicates Pin
Saamir10-Apr-07 5:07
Saamir10-Apr-07 5:07 
AnswerRe: Listview and remove or disallow duplicates Pin
Saamir10-Apr-07 6:51
Saamir10-Apr-07 6:51 
QuestionReference type or not Pin
hamidkhan10-Apr-07 4:38
hamidkhan10-Apr-07 4:38 
There is an explanation about how to raise events in MSDN at the address below:
http://msdn2.microsoft.com/en-us/library/ms173168.aspx
It says:
To avoid a race condition where the last handler can be removed between the null check and the invocation of the event, event sources should also create a copy of the event before performing the null check and raising the event.

private void RaiseTestEvent()
{
// Safely invoke an event:
TestEventDelegate temp = TestEvent;

if (temp != null)
{
temp(this, new System.EventArgs());
}
}

But Isn't the delegate TestEventDelegate a reference type? If I'm right, then assiging the Event TestEvent to the temp variable should not make a seperate object with similar data and state. It should rather create another pointer to the same object as it's supposed to do in reference types realm. So even in the race condition mentioned above, creating the temp variable should not be a solution. Because in that situation, removing the last event will cause the temp variable become null just like TestEvent. However the code above works well and eliminates the race condition. This makes a confusion for me on how it's possible that the variables are reference types while the code works well.
Any idea?D'Oh! | :doh:
AnswerRe: Reference type or not Pin
Guffa10-Apr-07 7:08
Guffa10-Apr-07 7:08 
QuestionRe: Reference type or not Pin
hamidkhan10-Apr-07 7:28
hamidkhan10-Apr-07 7:28 
AnswerRe: Reference type or not Pin
Guffa10-Apr-07 8:16
Guffa10-Apr-07 8:16 
QuestionCombobox value Pin
msogun10-Apr-07 4:26
msogun10-Apr-07 4:26 
AnswerRe: Combobox value Pin
mark_w_10-Apr-07 5:39
mark_w_10-Apr-07 5:39 
QuestionDataGridView validation Pin
7110-Apr-07 3:56
7110-Apr-07 3:56 
AnswerRe: DataGridView validation Pin
Sathesh Sakthivel10-Apr-07 4:17
Sathesh Sakthivel10-Apr-07 4:17 
AnswerRe: DataGridView validation Pin
sundeeppatil10-Apr-07 11:18
sundeeppatil10-Apr-07 11:18 
QuestionHelp regarding password char in textbox Pin
anu8110-Apr-07 3:56
anu8110-Apr-07 3:56 
AnswerRe: Help regarding password char in textbox Pin
gauthee10-Apr-07 4:05
gauthee10-Apr-07 4:05 
GeneralRe: Help regarding password char in textbox Pin
anu8110-Apr-07 4:14
anu8110-Apr-07 4:14 
GeneralRe: Help regarding password char in textbox Pin
althamda10-Apr-07 5:13
althamda10-Apr-07 5:13 
GeneralRe: Help regarding password char in textbox Pin
anu8110-Apr-07 19:03
anu8110-Apr-07 19:03 
GeneralRe: Help regarding password char in textbox Pin
gauthee10-Apr-07 18:36
gauthee10-Apr-07 18:36 
AnswerRe: Help regarding password char in textbox Pin
nikanth10-Apr-07 4:25
nikanth10-Apr-07 4:25 
QuestionTruncate decimal place Pin
polishprogrammer10-Apr-07 3:36
polishprogrammer10-Apr-07 3:36 
AnswerRe: Truncate decimal place Pin
gauthee10-Apr-07 3:48
gauthee10-Apr-07 3:48 

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.