Created
September 10, 2019 21:46
-
-
Save ezirmusitua/3a89cd740a6fd5d74410442699d815fb to your computer and use it in GitHub Desktop.
[Use Action as parameter with unlimited parameters] #C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 不加参数的 Action 参数可以传拥有任意数目参数的函数 | |
protected void udpCommand(Action command) | |
{ | |
while(!linkDownFail) | |
{ | |
try | |
{ | |
command(); | |
break; | |
} | |
catch | |
{ | |
LinkStateCallBack(ip, getLinkStatus()); | |
if (linkDownFail) throw new LinkDownException(); | |
Thread.Sleep(100); | |
} | |
} | |
return; | |
} | |
udpCommand(() => noParameterMethod()); | |
udpCommand(() => singleParameterMethod(value)); | |
udpCommand(() => manyParameterMethod(value, value2, value3, value4)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment