static void StopBreakdance() { if (breakdanceTimerSource != IntPtr.Zero) { Dispatch.Cancel(breakdanceTimerSource); breakdanceTimerSource = IntPtr.Zero; } }
static void CreateAgent(AgentStartOptions startOptions) { StopBreakdance(); var source = IntPtr.Zero; source = Dispatch.ScheduleRepeatingTimer(TimeSpan.FromSeconds(0), userdata => { Dispatch.Cancel(source); agent = new UnifiedAgent().Start(startOptions); }); }