????2. ??з?????????е???????????
??????????????????????SyncSignalProvider????仯?????????????????????
public delegate bool SyncSignalProvider();
//get syncsignal by auto mode
public bool GetSyncAuto()
{
//?????????????
return true;
}
//get syncsignal by manul mode
public bool GetSyncManul()
{
//?????????????
return false;
}
//??????
public void RefreshSyncSignal(SyncSignalProvider getSyncSignal)
{
bool sync = getSyncSignal();
if (sync)
{
//do something...
}
else
{
//do others...
}
}
//??з???仯???
public void TestDelegate()
{
RefreshSyncSignal(new SyncSignalProvider(GetSyncAuto));
}
????????????????????????:
????1. ?????????SyncSignalProvider????????????????????????????????bool????????????????????True??False?????????????
????2. ???????????????????????GetSyncAuto/GetSyncManul??????????????????????????????(bool?????????)??
????3. ??????????????????RefreshSyncSiganl????????????????????????getSyncSiganl???÷???????????????????????????????????????????????????????????????????????????????????д???????????????仯????????????????????仯????
????4. ??????????????TestDelegate???÷???????RefreshSyncSiganl???????????ж??? new SyncSignalProvider??GetSyncAuto??????????????????GetsyncAuto??????????????????????????
??????????????????????????????????????????????????RefreshSyncSiganl??????????GetSyncManul????п????????????????RefreshSyncSiganl??????
?????????????????????????????????????仯???????С?????