public void RaiseEventA(int a, string b, EventArgs c) { HelperDelegate delegateInstance = EventA; if (delegateInstance != null) { delegateInstance(a, b, c); } }
private void toolStripButtonRaiseEvent_Click(object sender, EventArgs e) { HelperDelegate delegateInstance = EventOne; if (delegateInstance != null) { delegateInstance("Raise param"); Report("Event raised..."); } }
private void toolStripButtonRaiseEvent_Click(object sender, EventArgs e) { HelperDelegate del = EventOne; if (del != null) { string param = "client: " + _poolClient.Id.ToString() + ", param: " + this.toolStripTextBox1.Text; del(param); Report("Raised [" + param + "]."); } }
/// <summary> /// Вычисление времени работы выбранного алгоритма /// </summary> /// <param name="batchSize">Количество итераций</param> /// <param name="argumentCount">Количество аргументов</param> /// <param name="method">Алгоритм</param> /// <param name="randomMin">Минимальное значение чисел, использующихся в алгоритме</param> /// <param name="randomMax">Максимальное значение чисел, использующихся в алгоритме</param> /// <returns>Время, затраченное на вычисления</returns> public static TimeSpan GetRandomBatchTime(int batchSize = _defaultBatchSize, int argumentCount = _defaultArgumentCount, GCDMethod method = GCDMethod.GCD, int randomMin = _randomMin, int randomMax = _randomMax) { if (batchSize < 1 || argumentCount < 2 || randomMin < 0) { throw new ArgumentOutOfRangeException(); } // (4 * batchSize * argumentCount) bytes if cached uint[][] values = new uint[batchSize][]; for (int i = 0; i < batchSize; ++i) { values[i] = (new uint[argumentCount]).Select(val => (uint)_rnd.Next(randomMin, randomMax)).ToArray(); } HelperDelegate helper = null; switch (method) { case GCDMethod.BinaryGCD: helper = BinaryGCD; break; case GCDMethod.GCD: helper = GCD; break; } _stopwatch.Start(); for (int i = 0; i < batchSize; ++i) { _ = helper(values[i]); } _stopwatch.Stop(); TimeSpan elapsed = _stopwatch.Elapsed; _stopwatch.Reset(); return(elapsed); }
// Enables and disables UI, also makes sure it runs on UI thread void SetDoingLengthyOperation(Boolean working) { if (this.InvokeRequired) { // Make sure we run on UI thread // Create a delegate to self HelperDelegate setDoingLengthyOperation = new HelperDelegate(this.SetDoingLengthyOperation); // Roll arguments in an Object array Object[] arguments = new Object[] { working }; // "Recurse once, onto another thread" this.Invoke(setDoingLengthyOperation, arguments); return; // return; } // If this is executing then the call occured on the UI thread // so we can freely access controls if (working) { TabControl.SelectedTab = TabPagePrincipal; //TabPagePrincipal.Select(); //TabPagePrincipal.Focus(); salvar(); BtnSincronizar.Enabled = false; //btnCancelar.Enabled = true; this.Cursor = Cursors.WaitCursor; } else { BtnSincronizar.Enabled = true; this.Cursor = Cursors.Arrow; tmrSincronizacao.Enabled = true; } }
public MyClass(HelperDelegate helper) { _myHelperDelegate = helper; }