Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
psycik11-Jul-12 23:51
psycik11-Jul-12 23:51 
GeneralRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
BobJanova13-Jul-12 4:14
BobJanova13-Jul-12 4:14 
QuestionQuery on Delegate Pin
ashish711-Jul-12 21:23
ashish711-Jul-12 21:23 
AnswerRe: Query on Delegate Pin
OriginalGriff11-Jul-12 21:37
mveOriginalGriff11-Jul-12 21:37 
GeneralRe: Query on Delegate Pin
Simon_Whale11-Jul-12 22:27
Simon_Whale11-Jul-12 22:27 
GeneralRe: Query on Delegate Pin
ashish711-Jul-12 22:29
ashish711-Jul-12 22:29 
GeneralRe: Query on Delegate Pin
DaveyM6911-Jul-12 22:48
professionalDaveyM6911-Jul-12 22:48 
GeneralRe: Query on Delegate Pin
OriginalGriff11-Jul-12 22:55
mveOriginalGriff11-Jul-12 22:55 
Sorry - I missed that the event keyword was missing - blame the lack of coffee! Laugh | :laugh:

In this case, all that is happening is that EventHandler is being used as the prototype for the method signature.

Or, in plainer English:

The GameStarted variable is declared as being an EventHandler - which is a delegate returning a void, and accepting an object and an EventArgs as parameters. The code
C#
this.game.GameStarted += delegate
           {
               this.ResetWinTransition.Begin();
               this.StatusPanel.Visibility = Visibility.Visible;
               this.TapToContinueTextBlock.Opacity = 0;
               this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
           };

adds an anonymous method to the execution list, so that when later the code:
C#
GameStarted(null, null); 
is executed, the anonymous method is called - as are any others that have been added.
Basically, whoever wrote the code is too lazy to declare his own method prototype which has no parameters, so he uses one which happens to exist already. Really he should have created his own delegate type to avoid any confusion:
C#
public delegate void GameMethod();
public GameMethod GameStarted;
He could then have executed the chained list of methods by calling:
C#
GameStarted();
Instead of supplying unused parameters.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

GeneralRe: Query on Delegate Pin
ashish711-Jul-12 23:13
ashish711-Jul-12 23:13 
GeneralRe: Query on Delegate Pin
Pete O'Hanlon11-Jul-12 23:23
mvePete O'Hanlon11-Jul-12 23:23 
GeneralRe: Query on Delegate Pin
BobJanova11-Jul-12 23:41
BobJanova11-Jul-12 23:41 
GeneralRe: Query on Delegate Pin
Pete O'Hanlon11-Jul-12 22:50
mvePete O'Hanlon11-Jul-12 22:50 
GeneralRe: Query on Delegate Pin
OriginalGriff11-Jul-12 22:56
mveOriginalGriff11-Jul-12 22:56 
GeneralRe: Query on Delegate Pin
DaveyM6911-Jul-12 22:57
professionalDaveyM6911-Jul-12 22:57 
GeneralRe: Query on Delegate Pin
Wayne Gaylard11-Jul-12 23:02
professionalWayne Gaylard11-Jul-12 23:02 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 2:15
ashish712-Jul-12 2:15 
GeneralRe: Query on Delegate Pin
OriginalGriff12-Jul-12 2:23
mveOriginalGriff12-Jul-12 2:23 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 2:32
ashish712-Jul-12 2:32 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 2:44
ashish712-Jul-12 2:44 
QuestionRe: Query on Delegate Pin
DaveyM6912-Jul-12 3:22
professionalDaveyM6912-Jul-12 3:22 
AnswerRe: Query on Delegate Pin
ashish712-Jul-12 3:31
ashish712-Jul-12 3:31 
GeneralRe: Query on Delegate Pin
DaveyM6912-Jul-12 7:38
professionalDaveyM6912-Jul-12 7:38 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 7:53
ashish712-Jul-12 7:53 
GeneralRe: Query on Delegate Pin
OriginalGriff12-Jul-12 3:48
mveOriginalGriff12-Jul-12 3:48 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 3:58
ashish712-Jul-12 3:58 

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.