Can someone explain this to me. I have this code, but I don’t know what that means.
void ConnectionManager_ConnectionFailed(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker)delegate()
{
if (cbAutoConnect.Checked)
Connect();
else
State = ConnectState.NotFound;
});
}
My question is:
Is this method an EventHandler?
What is the purpose of this code?
BeginInvoke ((MethodInvoker) delegate () {
What happened to the "Condition" when the "Else" condition was met?
Note:
Connection is a method.
Status is an enumeration describing this code.
public ConnectState State
{
get
{
return _State;
}
{
if (_State == value)
return;
_State = value;
switch (value)
{
case ConnectState.Connected:
DoingSomeThing;
break;
case ConnectState.Connecting:
DoingSomeThing;
break;
case ConnectState.NotFound:
DoingSomeThing;
break;
}
if (StateChanged != null)
StateChanged(this, new EventArgs<ConnectState>(value));
}
}
Another tip
Enumeration Initiation
public enum ConnectState { Connected, Connecting, NotFound }
ConnectState _State = ConnectState.NotFound;
I don't know what it is for sure, but I think it is a custom EventHandler declaration for the ConnectState object / class.
public EventHandler<EventArgs<ConnectState>> StateChanged;
source
share