internal static bool ScheduleWork(string sTaskName, uint iMaxDelay, SimpleEventHandler workFunction) { try { _RWLockDict.AcquireReaderLock(-1); if (_dictSchedule.ContainsKey(sTaskName)) { return false; } } finally { _RWLockDict.ReleaseReaderLock(); } jobItem item = new jobItem(workFunction, iMaxDelay); try { _RWLockDict.AcquireWriterLock(-1); if (_dictSchedule.ContainsKey(sTaskName)) { return false; } _dictSchedule.Add(sTaskName, item); if (_timerInternal == null) { _timerInternal = new Timer(new TimerCallback(ScheduledTasks.doWork), null, 15, 15); } } finally { _RWLockDict.ReleaseWriterLock(); } return true; }
public void EventTest() { SimpleEvent += new SimpleEventHandler(OnSimpleEvent); method = GetMethodForTest("OnSimpleEvent"); messageCollection = rule.CheckMethod(method, new MinimalRunner()); Assert.IsNull(messageCollection); }
public static int Install(DebugUtilities debugUtilities, out SimpleEventHandler eventCallbacks, BREAKPOINT_HANDLER breakpointHandler = null) { var ec = new SimpleEventHandler(debugUtilities); if (breakpointHandler != null) { ec._breakpointHandler = breakpointHandler; } IDebugEventCallbacks idec = ec; IntPtr unknownPtr = Marshal.GetIUnknownForObject(idec); IntPtr idecPtr; Guid guid = typeof(IDebugEventCallbacks).GUID; int hr = Marshal.QueryInterface(unknownPtr, ref guid, out idecPtr); if (FAILED(hr)) { ec.Dispose(); eventCallbacks = null; return(hr); } debugUtilities.DebugClient.GetEventCallbacks(out ec._previousCallbacks); /* We will need to release this */ hr = debugUtilities.DebugClient.SetEventCallbacks(idecPtr); if (FAILED(hr)) { ec.Dispose(); eventCallbacks = null; return(hr); } ec._installed = true; eventCallbacks = ec; return(hr); }
public void Setup() { _cqrsLogicHandler = TestApplicationState.Container.Resolve <CqrsLogicHandler>(); _cqrsLogicHandler.Start(); _simpleCommandHandler = TestApplicationState.Container.Resolve <SimpleCommandHandler>(); _simpleEventHandler = TestApplicationState.Container.Resolve <SimpleEventHandler>(); }
/// <summary> /// Creates a new SimpleDebugger object with the required parameters. /// </summary> /// <param name="originatingClient">An IDebugClient interface associated with the connection</param> /// <param name="processId">The ID of the process being debugged</param> /// <param name="connectionIsPassive">True if the debugger is passively attached to the target</param> /// <param name="outputHandler">A SimpleOutputHandler which is receiving the debugger output</param> /// <param name="eventHandler">A SimpleEventHandler to handle the debugger events</param> public SimpleDebugger(DebugUtilities originatingClient, uint processId, bool connectionIsPassive, SimpleOutputHandler outputHandler, SimpleEventHandler eventHandler) { _OriginatingDebugUtilities = originatingClient; ProcessID = processId; DebuggerIsPassive = connectionIsPassive; _OutputHandler = outputHandler; _EventHandler = eventHandler; }
internal taskItem assignWork(SimpleEventHandler workFunction, uint iMS) { taskItem item = new taskItem(workFunction, iMS); lock (this.oTaskList) { this.oTaskList.Add(item); } return item; }
/// <summary>Invokes the action and event callbacks.</summary> /// <param name="state">The progress value.</param> private void InvokeEvent(object state) { SimpleEventHandler <PiciObservableCollectionWithCancellationToken <T> > changedEvent = ListUpdated; if (changedEvent != null) { changedEvent(this); } }
internal void OnFiddlerDetach() { SimpleEventHandler handler = FiddlerDetach; if (handler != null) { handler(); } }
public void UnregisterSimpleEventHandler(string type, SimpleEventHandler handler) { if (!simpleEventHandlers.ContainsKey(type)) { throw new InvalidOperationException(@"handler " + handler + @" cannot be unregistered for simple event type " + type + @" because it was not registered."); } simpleEventHandlers[type] -= handler; }
internal taskItem assignWork(SimpleEventHandler workFunction, uint iMS) { taskItem item = new taskItem(workFunction, iMS); lock (this.oTaskList) { this.oTaskList.Add(item); } return(item); }
private static int ConnectDebuggerDumpHelper(DebugUtilities debugUtilities, string dumpFile, out SimpleDebugger debuggerInformation) { int hr; SimpleOutputHandler debuggerOutputCallbacks = null; SimpleEventHandler debuggerEventCallbacks = null; debuggerInformation = null; hr = SimpleOutputHandler.Install(debugUtilities, out debuggerOutputCallbacks); if (hr != S_OK) { goto Error; } hr = SimpleEventHandler.Install(debugUtilities, out debuggerEventCallbacks); if (hr != S_OK) { goto ErrorWithDetach; } hr = debugUtilities.DebugClient.OpenDumpFileWide(dumpFile, 0); if (FAILED(hr)) { goto ErrorWithDetach; } while (debuggerEventCallbacks.SessionIsActive == false) { hr = debugUtilities.DebugControl.WaitForEvent(DEBUG_WAIT.DEFAULT, 50); if (FAILED(hr)) { goto ErrorWithDetach; } } debuggerInformation = new SimpleDebugger(debugUtilities, 0, true, debuggerOutputCallbacks, debuggerEventCallbacks); goto Exit; ErrorWithDetach: debugUtilities.DebugClient.DetachProcesses(); debugUtilities.DebugClient.EndSession(DEBUG_END.ACTIVE_DETACH); Error: if (debuggerEventCallbacks != null) { debuggerEventCallbacks.Dispose(); } if (debuggerOutputCallbacks != null) { debuggerOutputCallbacks.Dispose(); } Exit: return(hr); }
public void TestBasicHandler() { bool handled = false; var handler = new SimpleEventHandler<MyTestCommand>( (cmd, seq, endOfBatch) => { handled = true; }); handler.OnNext(new MyTestCommand(), 0, false); Assert.That(handled, Is.True); }
internal void FireListUpdated() { SimpleEventHandler <PiciObservableCollectionWithCancellationToken <T> > changedEvent = ListUpdated; if (changedEvent != null) { // Post the processing to the [....] context. // (If T is a value type, it will get boxed here.) m_synchronizationContext.Post(m_StatusHandler, null); } }
public void RegisterSimpleEventHandler(string type, SimpleEventHandler handler) { if (!simpleEventHandlers.ContainsKey(type)) { simpleEventHandlers.Add(type, handler); } else { simpleEventHandlers[type] += handler; } }
private void button1_Click(object sender, EventArgs e) { CustomerType ct; ct = CustomerType.Retail; if (ct == CustomerType.Retail) { Console.WriteLine("test"); } SimpleEventHandler seh = new SimpleEventHandler(RunCode); seh.Invoke("A Message!"); }
public virtual void Abort() { StopCoroutine(this.snap); if( isLocal ){ this.transform.localPosition = this.from; }else{ this.transform.position = from; } this.OnStartSnapReaction = null; this.OnFinishSnapReaction = null; }
public PrototypeDevice() { DcClient = new DeviceHive.HttpClient(Resources.GetString(Resources.StringResources.CloudUrl), DateTime.MinValue, RequestTimeout); Initializing += new ConnectEventHandler(PreInit); Connecting += new ConnectEventHandler(PreConnect); Connected += new ConnectEventHandler(PostConnect); BeforeCommand += new CommandEventHandler(PreProcessCommand); AfterCommand += new CommandEventHandler(PostProcessCommand); BeforeNotification += new NotificationEventHandler(PreProcessNotification); AfterNotification += new NotificationEventHandler(PostProcessNotification); Disconnected += new SimpleEventHandler(OnDisconnect); LastTemp = 0.0f; }
internal PeriodicWorker.taskItem assignWork(SimpleEventHandler workFunction, uint iMS) { PeriodicWorker.taskItem taskItem = new PeriodicWorker.taskItem(workFunction, iMS); List <PeriodicWorker.taskItem> obj; Monitor.Enter(obj = this.oTaskList); try { this.oTaskList.Add(taskItem); } finally { Monitor.Exit(obj); } return(taskItem); }
public Handle Subscribe(SimpleEventHandler handler, bool includeLast = false) { if (this.handlers == null) { this.handlers = new List <SimpleEventHandler>(); } this.handlers.Add(handler); if (this.lastEvent != null && includeLast) { handler.Invoke(this.lastEvent); } return(new Handle(() => this.Unsubscribe(handler))); }
public Model() { handler = MyMessageEvent; _randomNumber = new Random(); _subscriber1Thread = new Thread(new ThreadStart(Subscriber1ThreadFunction)); _subscriber1ThreadIsRunning = true; _subscriber1Thread.Start(); _subscriber2Thread = new Thread(new ThreadStart(Subscriber2ThreadFunction)); _subscriber2ThreadIsRunning = true; _subscriber2Thread.Start(); _subscriber3Thread = new Thread(new ThreadStart(Subscriber3ThreadFunction)); _subscriber3ThreadIsRunning = true; _subscriber3Thread.Start(); }
void Subscriber2ThreadFunction() { handler += new SimpleEventHandler(Subscriber2Handler); try { while (_subscriber2ThreadIsRunning == true) { Subscriber2Data = _randomNumber.Next(101, 200).ToString(); Thread.Sleep(_randomNumber.Next(200, 500)); } } catch (System.Threading.ThreadAbortException) { Console.WriteLine("Thread 2 is aborted"); } }
public async Task Publish_UsingGenericInterfaceWithNoArguments_ShouldPublishAwaitable() { //---------------Set up test pack------------------- var sut = Create(); var handler = new SimpleEventHandler(); sut.Subscribe(handler); //---------------Assert Precondition---------------- Assert.IsNull(handler.ReceivedMessage); //---------------Execute Test ---------------------- await sut.Publish <SimpleEvent>(); //---------------Test Result ----------------------- Assert.IsNotNull(handler.ReceivedMessage); }
public int Test(int v) { int v1 = 0, v2; GenericClass <int> f = new GenericClass <int>(ref v1, out v2); int v = f[3, 4]; f[4, 5] = 6; f[4, 5] = Test2(1, 2, ref v1, out v2); v = Test2(1, 2, ref v1, out v2); Test2(1, 2, ref v1, out v2); v = 1 + Test2(1, 2, ref v1, out v2); v += Test2(1, 2, ref v1, out v2); v2 = (v = Test2(1, 2, ref v1, out v2)); f.Test(v); OnSimple += () => { }; { OnSimple2 += () => { }; } }
public void TestServiceHandler() { bool handled = false; DateTimeOffset eventTime = DateTimeOffset.UtcNow; var clockMock = new Mock<IUtcClockService>(); clockMock .SetupGet(o => o.UtcNow) .Returns(new DateTimeOffset(new DateTime(2016, 04, 01))); var handler = new SimpleEventHandler<IUtcClockService, MyTestCommand>(clockMock.Object, (businessLogic, cmd, seq, endOfBatch) => { eventTime = businessLogic.UtcNow; handled = true; }); handler.OnNext(new MyTestCommand(), 0, false); Assert.That(handled, Is.True); Assert.That(eventTime, Is.EqualTo(new DateTimeOffset(new DateTime(2016, 04, 01)))); }
private void Unsubscribe(SimpleEventHandler handler) { Debug.Log("Unsubscribe"); if (this.handlers == null) { return; } int idx = this.handlers.IndexOf(handler); if (idx != -1) { this.handlers.RemoveAt(idx); } if (this.handlers.Count == 0) { this.handlers = null; } }
/// <summary> /// Detaches from the target process /// </summary> public void Detach(bool detaching) { if (Detached == false && detaching == true) { if (OutputHandler != null) { OutputHandler.Dispose(); _OutputHandler = null; } if (EventHandler != null) { EventHandler.Dispose(); _EventHandler = null; } if (OriginatingDebugUtilities != null) { OriginatingDebugUtilities.DebugClient.DetachProcesses(); OriginatingDebugUtilities.DebugClient.EndSession(DEBUG_END.ACTIVE_DETACH); DebugUtilities.ReleaseComObjectSafely(OriginatingDebugUtilities); _OriginatingDebugUtilities = null; } Detached = true; } }
internal static bool ScheduleWork(string sTaskName, uint iMaxDelay, SimpleEventHandler workFunction) { try { ScheduledTasks._RWLockDict.AcquireReaderLock(-1); if (ScheduledTasks._dictSchedule.ContainsKey(sTaskName)) { bool result = false; return(result); } } finally { ScheduledTasks._RWLockDict.ReleaseReaderLock(); } ScheduledTasks.jobItem value = new ScheduledTasks.jobItem(workFunction, iMaxDelay); try { ScheduledTasks._RWLockDict.AcquireWriterLock(-1); if (ScheduledTasks._dictSchedule.ContainsKey(sTaskName)) { bool result = false; return(result); } ScheduledTasks._dictSchedule.Add(sTaskName, value); if (ScheduledTasks._timerInternal == null) { ScheduledTasks._timerInternal = new Timer(new TimerCallback(ScheduledTasks.doWork), null, 15, 15); } } finally { ScheduledTasks._RWLockDict.ReleaseWriterLock(); } return(true); }
/// <summary>Creates timer associated with the form.</summary> /// <param name="interval"> /// The interval in milliseconds between consecutive ticks of the timer. /// </param> /// <param name="tickHandler">The event handler for the timer's tick.</param> public SimpleTimer CreateTimer(int interval, SimpleEventHandler tickHandler) { return this.CreateTimer(interval, (tmr) => tickHandler.Invoke()); }
public DeligateCommand(SimpleEventHandler handler) { _handler = handler; }
public jobItem(SimpleEventHandler oJob, uint iMaxDelay) { this._ulRunAfter = iMaxDelay + Utilities.GetTickCount(); this._oJob = oJob; }
public void EventTest () { SimpleEvent += new SimpleEventHandler (OnSimpleEvent); method = GetMethodForTest ("OnSimpleEvent"); messageCollection = rule.CheckMethod (method, new MinimalRunner ()); Assert.IsNull (messageCollection); }
/// <summary>Adds a button to the form.</summary> /// <param name="caption">The caption to display on the button.</param> /// <param name="clickHandler">The click event handler.</param> /// <param name="buttonWidth">Width of the button.</param> public SimpleButton AddButton(string caption, SimpleEventHandler clickHandler, int buttonWidth = -1) { return this.AddButton(caption, (sbtn) => clickHandler.Invoke(), buttonWidth); }
private void button1_Click(object sender, EventArgs e) { CustomerType objCT; //Enumeration SimpleEventHandler objSEH; //Delegate IPerson objIP; //Interface PersonClass objPC; //Abstract Class Customer objC; //"Concrete + Child + Sealed" Class PersonStructure objPS; //Structure /** Using an Enumeration **/ objCT = new CustomerType(); objCT = CustomerType.Retail; if (objCT == CustomerType.Retail) { Console.WriteLine("Retail Customer"); } /** Using an Delegate **/ objSEH = new SimpleEventHandler(MyEventHanderMethod); objSEH.Invoke("Invoking the Method through the Delegate!"); /** Using an Interface **/ //objIP = new PersonClass; objIP = new PersonStructure(); objIP.DOBChanged += new SimpleEventHandler(MyEventHanderMethod); objIP.NameChanged += new SimpleEventHandler(MyEventHanderMethod); objIP.Name = "Bob"; objIP.DOB = "01/01/80"; Console.WriteLine(objIP.GetPersonalData()); //Console.WriteLine(objIP.GetPersonalData("|")); /** Using an Abstract Class **/ //objPC = new PersonClass; //objPC = new PersonStructure(); objPC = new Customer(); objPC.DOBChanged += new SimpleEventHandler(MyEventHanderMethod); objPC.NameChanged += new SimpleEventHandler(MyEventHanderMethod); objPC.Name = "Bob"; objPC.DOB = "01/01/80"; Console.WriteLine(objPC.GetPersonalData()); //Console.WriteLine(objPC.GetPersonalData("|")); /** Using an "Concrete + Child + Sealed" Class **/ //objC = new PersonCustomer; //objC = new PersonStructure(); objC = new Customer(); objC.DOBChanged += new SimpleEventHandler(MyEventHanderMethod); objC.NameChanged += new SimpleEventHandler(MyEventHanderMethod); objC.Name = "Bob"; objC.DOB = "01/01/80"; Console.WriteLine(objC.GetPersonalData()); Console.WriteLine(objC.GetPersonalData("|")); /** Using an Structure **/ //objPS = new PersonClass; objPS = new PersonStructure(); //objPS = new Customer(); objPS.DOBChanged += new SimpleEventHandler(MyEventHanderMethod); objPS.NameChanged += new SimpleEventHandler(MyEventHanderMethod); objPS.Name = "Bob"; objPS.DOB = "01/01/80"; Console.WriteLine(objPS.GetPersonalData()); //Console.WriteLine(objPS.GetPersonalData("|")); }
public NotifyOnRecieveEvent(T1 innerEvent, SimpleEventHandler <T2> resp) { InnerEvent = innerEvent; Response = resp; }
public DelegateCommand(SimpleEventHandler eventHandler) { _eventHandler = eventHandler; }
public taskItem(SimpleEventHandler oTask, uint iPeriod) { this._iPeriod = iPeriod; this._oTask = oTask; }
public DelegateCommand(SimpleEventHandler handler) { _handler = handler ?? throw new ArgumentNullException(nameof(handler)); }
public void EventTest() { SimpleEvent += new SimpleEventHandler(OnSimpleEvent); AssertRuleDoesNotApply <AvoidUnusedParametersTest> ("OnSimpleEvent"); }
public DelegateCommand(SimpleEventHandler handler) { this.handler = handler; }
private static int ConnectDebuggerLiveHelper(DebugUtilities debugUtilities, uint processID, bool passive, out SimpleDebugger debuggerInformation) { int hr; IDebugControl debugControl = null; IDebugSystemObjects debugSystemObjects = null; SimpleOutputHandler debuggerOutputCallbacks = null; SimpleEventHandler debuggerEventCallbacks = null; debuggerInformation = null; hr = SimpleOutputHandler.Install(debugUtilities, out debuggerOutputCallbacks); if (hr != S_OK) { goto Error; } hr = SimpleEventHandler.Install(debugUtilities, out debuggerEventCallbacks); if (hr != S_OK) { goto ErrorWithDetach; } DEBUG_ATTACH attachFlags = passive ? DEBUG_ATTACH.NONINVASIVE | DEBUG_ATTACH.NONINVASIVE_NO_SUSPEND : DEBUG_ATTACH.INVASIVE_RESUME_PROCESS; hr = debugUtilities.DebugClient.AttachProcess(0, processID, attachFlags); if (hr != S_OK) { goto ErrorWithDetach; } while (debuggerEventCallbacks.SessionIsActive == false) { hr = debugControl.WaitForEvent(DEBUG_WAIT.DEFAULT, 50); if (FAILED(hr)) { goto ErrorWithDetach; } } bool foundMatchingProcess = false; uint numProcesses; debugSystemObjects.GetNumberProcesses(out numProcesses); uint[] systemProcessIDs = new uint[numProcesses]; uint[] engineProcessIDs = new uint[numProcesses]; hr = debugSystemObjects.GetProcessIdsByIndex(0, numProcesses, engineProcessIDs, systemProcessIDs); for (uint i = 0; i < numProcesses; ++i) { if (systemProcessIDs[i] == processID) { foundMatchingProcess = true; hr = debugSystemObjects.SetCurrentProcessId(engineProcessIDs[i]); if (FAILED(hr)) { debuggerOutputCallbacks.AddNoteLine(String.Format(CultureInfo.InvariantCulture, "ERROR! Failed to set the active process! hr={0:x8}", hr)); goto ErrorWithDetach; } break; } } if (foundMatchingProcess == false) { hr = E_FAIL; debuggerOutputCallbacks.AddNoteLine(String.Format(CultureInfo.InvariantCulture, "ERROR! The debugger engine could not find the requested process ID ({0})!", processID)); goto ErrorWithDetach; } debuggerInformation = new SimpleDebugger(debugUtilities, processID, passive, debuggerOutputCallbacks, debuggerEventCallbacks); goto Exit; ErrorWithDetach: debugUtilities.DebugClient.DetachProcesses(); debugUtilities.DebugClient.EndSession(DEBUG_END.ACTIVE_DETACH); Error: if (debuggerEventCallbacks != null) { debuggerEventCallbacks.Dispose(); } if (debuggerOutputCallbacks != null) { debuggerOutputCallbacks.Dispose(); } Exit: return(hr); }
/// <summary>Adds a button to the form.</summary> /// <param name="caption">The caption to display on the button.</param> /// <param name="clickHandler">The click event handler.</param> /// <param name="buttonWidth">Width of the button.</param> public SimpleButton AddButton(string caption, SimpleEventHandler clickHandler, int buttonWidth = -1) { return(this.AddButton(caption, (sbtn) => clickHandler.Invoke(), buttonWidth)); }
// // Define the eventHandler method public virtual void OnSimpleEventHandler() { SimpleEventHandler?.Invoke(this, EventArgs.Empty); Console.Write("Running Event : OnSimpleEventHandler ", Environment.NewLine); }