public void PlayBigWinAnimation(SimpleDel callback) { _registeredCallback = callback; coinSpewer.StartCoins(); gameObject.SetActive(true); GetComponent <Animator>().SetTrigger("ActivateBigWinTrigger"); }
IEnumerator onComplete(Animation anim, SimpleDel callback) { while (anim.isPlaying) { yield return(null); } callback(); }
static void ShowAllDelegatMethodsExample() { Console.WriteLine("Show all delegat methods example"); SimpleDel hello = Hello; SimpleDel goodbye = Goodbye; SimpleDel multicast1 = hello + goodbye; ShowAllMethods(multicast1); }
static void Main(string[] args) { int b = 20; var a = new SimpleDel(b1 => { Console.WriteLine("OKOK" + b1); //int c = args.Length; }); a(b); }
/// <summary> /// Старт мониторинга онлайна. /// </summary> public void RunOnline() { PositionThread = new ThreadTimer() { Period = 1000, Delay = 500 }; PositionThread.WorkChanged += PositionThread_WorkChanged; PositionThread.InterfaceChanged += PositionThread_InterfaceChanged; PositionThread.Run(); OnlineChangedDelegate = OnlineChangedMethod; OnlineCountChangedDelegate = OnlineCountChangedMethod; }
public void addCommon(string str) { if (this.InvokeRequired) { SimpleDel s = addCommon; this.Invoke(s, new object[] { str }); } else { GoComment comment = getCommon(); comment.Text = string.Format("{0}\n{1}", comment.Text, str); LogHelper.Info(str); } }
public static T SimpleWrap <T>(SimpleDelManager <T> instrumentedCode, SimpleDel <T> originalCode) { using (_ProtectingThreadContext.Acquire()) { if (WrapperSentry.Wrap()) { using (new WrapperSentry()) { ClrSyncManager manager = ClrSyncManager.SyncManager; return(instrumentedCode(manager)); } } else { return(originalCode()); } } }
static void MulticastDelegatExample() { SimpleDel hello = Hello; SimpleDel goodbye = Goodbye; SimpleDel multicast1 = hello + goodbye; SimpleDel multicast2 = (SimpleDel)Delegate.Combine(hello, goodbye); Console.WriteLine("Invoking hello delegat"); hello("Bojan"); Console.WriteLine("Invoking goodbye delegat"); goodbye("Bojan"); Console.WriteLine("Invoking multicast1 delegat"); multicast1("Bojan"); Console.WriteLine("Invoking multicast2 delegat"); multicast2("Bojan"); }
private void CheatHandler(Dictionary <string, int> options) { Debug.Log("CheatHandler called"); if (QuickPlayTool.GetBoardSize() == 4) { OnSelect4x4Grid(); } else { OnSelect3x3Grid(); } int player = options["whoWins"] == 0 ? 1 : -1; // start appropriate sequence of moves for selected game outcome. if (options["winType"] == 3) { _playbackMoves = _outcomeFinder.FindDrawGameSequence(_gameGrid.GetLength(0)); } else if (options["winType"] == 2) { if (options["diagonalDir"] == 0) { _playbackMoves = _outcomeFinder.FindFirstDiagonalGameSequence(_gameGrid.GetLength(0), player); } else { _playbackMoves = _outcomeFinder.FindSecondDiagonalGameSequence(_gameGrid.GetLength(0), player); } } else if (options["winType"] == 0) { // row win _playbackMoves = _outcomeFinder.FindRowGameSequence(_gameGrid.GetLength(0), player, options["row"]); } else if (options["winType"] == 1) { // col win _playbackMoves = _outcomeFinder.FindColGameSequence(_gameGrid.GetLength(0), player, options["col"]); } _playbackIndex = 0; _onUpdate += DoCheatMove; }
static void Main(string[] args) { SimpleDel simple = () => new Random().Next(0, 100); SimpleDel[] delegates = { simple, simple, simple }; Anon anon = (deleg) => { double a = 0; foreach (var item in deleg) { a += item(); Console.WriteLine(a); } return((double)a / deleg.Length); }; Console.WriteLine(anon(delegates)); Console.Read(); }
private void DoCheatMove() { _timeSinceLastCheatMove += Time.deltaTime; if (_timeSinceLastCheatMove > _playbackSpeed) { if (_playbackMoves == null) { _onUpdate -= DoCheatMove; return; } _timeSinceLastCheatMove = 0.0f; int col = _playbackMoves[_playbackIndex].col; int row = _playbackMoves[_playbackIndex].row; Button cell = _buttonGrid[col, row]; OnCellClicked(cell, col, row); _playbackIndex++; if (_playbackIndex >= _playbackMoves.Count) { _onUpdate -= DoCheatMove; } } }
public override void SaveUIInvoke(SimpleDel simpleDel) { WinFormCefMsgLoopPump.SafeUIInvoke(simpleDel); }
public abstract void SaveUIInvoke(SimpleDel simpleDel);
public override void SaveUIInvoke(SimpleDel simpleDel) { //invoke on ui thread**** //TODO: review here //WinFormCefMsgLoopPump.SafeUIInvoke(simpleDel); }
public static T SimpleContextExposingWrap <T>(SimpleDelManagerContext <T> instrumentedCode, SimpleDel <T> originalCode) { IDisposable protectingcontext = _ProtectingThreadContext.Acquire(); try { if (WrapperSentry.Wrap()) { using (new WrapperSentry()) { ClrSyncManager manager = ClrSyncManager.SyncManager; return(instrumentedCode(manager, ref protectingcontext)); } } else { return(originalCode()); } } finally { protectingcontext.Dispose(); } }
static void Main() { Sample sample = new Sample(); sample.Foo(); //Nullable types Nullable <int> x = null; int? y = null; x = 10; if (x.HasValue) { Console.WriteLine(x.Value); } //SimpleDel simpleDel = new SimpleDel(Print); //Method group conversions (delegates) SimpleDel simpleDel = Print; simpleDel(12); //anonymous method simpleDel = delegate(object obj) { Console.WriteLine($"Value: {obj}"); }; simpleDel("siemens"); //a --> implicitly typed local variable //type inference: technique where compiler understands (interprets) data type of implicitly typed local variable by looking at the assigned value var a = 10; var arr = new[] { 1, 2, 3, 4 }; var list = new List <int>(); foreach (var item in list) { } //Student student = new Student("siemens"); //student.Name = "anil"; //object initializer Student student = new Student { Name = "anil", SchoolName = "siemens" }; //collection initlaizer List <int> numbers = new List <int> { 1, 2, 3, 4 }; List <Student> students = new List <Student> { new Student { Name = "anil", SchoolName = "siemens" } }; //anonymous type var person = new { FirstName = "anil", LastName = "gupta" }; Console.WriteLine(person.GetType().Name); //person.FirstName = ""; //query expression IEnumerable <string> query = from s in students where s.Name.Contains('a') orderby s.Name select s.Name; //method expression IEnumerable <Student> filteredCollection = students.Where(s => s.Name.Contains('a')); IOrderedEnumerable <Student> sortedCollection = filteredCollection.OrderBy(s => s.Name); IEnumerable <string> finalCollection = sortedCollection.Select(s => s.Name); //Func<int, bool> del = (num) => num % 2 == 0; bool IsEven(int num) => num % 2 == 0; Console.WriteLine(IsEven(5)); void Test(out int m) => m = 12; Test(out int z); Console.WriteLine($"value of {nameof(z)} is {z}"); }
public static void SafeUIInvoke(SimpleDel simpleDel) { tinyForm.Invoke(simpleDel); }
public static void SafeUIInvoke(SimpleDel del) { cefInitEssential.SaveUIInvoke(del); }
public static void SafeUIInvoke(SimpleDel del) { Cef3WinForms.s_currentImpl.SaveUIInvoke(del); }