本文整理汇总了C#中System.Timers.Timer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Timer.Stop方法的具体用法?C# Timer.Stop怎么用?C# Timer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Timers.Timer
的用法示例。
在下文中一共展示了Timer.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: App
static App()
{
HeartBeatTimer = new Timer(10 * 1000);
//HeartBeatTimer.SynchronizingObject = null;
HeartBeatTimer.Elapsed += delegate
{
if (Server != null)
{
try
{
Server.GetVersion();
HeartBeatTimer.Start();
}
catch
{
try { Server.Abort(); }
catch { }
Server = null;
HeartBeatTimer.Stop();
MessageBox.Show("Disconnected from the server", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(1);
}
}
else
{
HeartBeatTimer.Stop();
}
};
HeartBeatTimer.AutoReset = false;
}
示例2: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
searchField.Text = string.Empty;
var keyStrokeTimer = new Timer (500);
var timeElapsedSinceChanged = true;
keyStrokeTimer.Start ();
keyStrokeTimer.Elapsed += (sender, e) => {
timeElapsedSinceChanged = true;
};
var searchText = "";
searchField.EditingChanged += async (sender, e) => {
keyStrokeTimer.Stop ();
if (timeElapsedSinceChanged) {
// Probably should do some locking
timeElapsedSinceChanged = false;
keyStrokeTimer.Stop ();
if (!string.IsNullOrEmpty (searchField.Text)) {
if (!searchText.Equals (searchField.Text)) {
searchText = searchField.Text;
var results = await SearchCheeses (searchText);
foreach (var cheeseName in results) {
Console.WriteLine ($"Cheese name: {cheeseName}");
}
}
}
}
keyStrokeTimer.Start();
};
// var editing = searchField.Events ().EditingChanged;
//
// var searchSteam = editing
// .Select (_ => searchField.Text)
// .Where (t => !string.IsNullOrEmpty (t))
// .DistinctUntilChanged ()
// .Throttle (TimeSpan.FromSeconds (0.5))
// .SelectMany (t =>
// SearchCheeses (t));
//
// searchSteam.Subscribe (
// r =>
// r.ForEach(cheeseName =>
// Console.WriteLine($"Cheese name: {cheeseName}"))
// );
}
示例3: PackageDownloader
public PackageDownloader(PlasmaDownloader plasmaDownloader)
{
this.plasmaDownloader = plasmaDownloader;
LoadRepositories();
refreshTimer = new Timer();
refreshTimer.Stop();
refreshTimer.AutoReset = true;
refreshTimer.Elapsed += RefreshTimerElapsed;
refreshTimer.Stop();
}
示例4: Main
static void Main(string[] args)
{
GenericPrincipal principal = new GenericPrincipal(new GenericIdentity("Miguel"), new string[] { "CarRentalAdmin" });
Thread.CurrentPrincipal = principal;
ObjectBase.Container = MEFLoader.Init();
Console.WriteLine("Starting up services");
Console.WriteLine("");
SM.ServiceHost hostInventoryManager = new SM.ServiceHost(typeof(InventoryManager));
SM.ServiceHost hostRentalManager = new SM.ServiceHost(typeof(RentalManager));
SM.ServiceHost hostAccountManager = new SM.ServiceHost(typeof(AccountManager));
StartService(hostInventoryManager, "InventoryManager");
StartService(hostRentalManager, "RentalManager");
StartService(hostAccountManager, "AccountManager");
System.Timers.Timer timer = new Timer(10000);
timer.Elapsed += OnTimerElapsed;
timer.Start();
Console.WriteLine("");
Console.WriteLine("Press [Enter] to exit.");
Console.ReadLine();
timer.Stop();
Console.WriteLine("Reservation Monitor Stopped");
StopService(hostInventoryManager, "InventoryManager");
StopService(hostRentalManager, "RentalManager");
StopService(hostAccountManager, "AccountManager");
}
示例5: ErrorHighlighter
public ErrorHighlighter(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte)
{
_view = view;
_document = document;
_text = new Adornment();
_tasks = tasks;
_dispatcher = Dispatcher.CurrentDispatcher;
_adornmentLayer = view.GetAdornmentLayer(ErrorHighlighterFactory.LayerName);
_view.ViewportHeightChanged += SetAdornmentLocation;
_view.ViewportWidthChanged += SetAdornmentLocation;
_text.MouseUp += (s, e) => { dte.ExecuteCommand("View.ErrorList"); };
_timer = new Timer(750);
_timer.Elapsed += (s, e) =>
{
_timer.Stop();
Task.Run(() =>
{
_dispatcher.Invoke(new Action(() =>
{
Update(false);
}), DispatcherPriority.ApplicationIdle, null);
});
};
_timer.Start();
}
示例6: RunSystemAdministrator
// GET: RunSystemAdministrator
public ActionResult RunSystemAdministrator()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://localhost:4601/");
var emp = _employeeService
.Queryable()
.Where(x => x.DepartmentRoleId == 9)
.FirstOrDefault();
emp.EmployeeLogin = _employeeLoginService
.Queryable()
.Where(x => x.EmployeeId == emp.EmployeeId)
.FirstOrDefault();
IWebElement UserName = driver.FindElement(By.Name("UserName"));
IWebElement Password = driver.FindElement(By.Name("Password"));
var loginButton = driver.FindElement(By.XPath("/html/body/div/div/div/section/form/button"));
UserName.SendKeys(emp.EmployeeLogin.UserName);
Password.SendKeys(emp.EmployeeLogin.Password);
loginButton.Click();
Timer timer = new Timer(1000);
timer.Start();
timer.Stop();
return View();
}
示例7: StartService
protected override void StartService()
{
try
{
//create and fire off a timer
//simply start our timer -- which will automatically kick off synchronizing
//if (_taskPoolManager != null)
// _taskPoolManager.ProgressChanged -= synchronizer_ProgressChanged;
//_taskPoolManager.ProgressChanged += synchronizer_ProgressChanged;
_pollTimer = new System.Timers.Timer()
{
Enabled = true,
Interval = _config.Interval.TotalMilliseconds
};
_pollTimer.Elapsed += pollTimer_Elapsed;
_pollTimer.Start();
}
catch (Exception ex)
{
_log.FatalException(String.Format("Service {0} - Unexpected Error - Failed to start", ServiceName), ex);
if (null != _pollTimer) _pollTimer.Stop();
if (null != _taskPoolManager)
{
try { _taskPoolManager.CancelAll(); }
catch (Exception) { };
}
//make sure that Windows knows that we're not running -- with the service messed, we can't
throw;
}
}
示例8: ComPort
//---------------------------------------------------------------------------
/// <summary>
/// Конструктор
/// </summary>
public ComPort()
{
_SyncRoot = new Object();
_СurrentTransaction =
new Modbus.OSIModel.Transaction.Transaction(TransactionType.Undefined, null);
_TimerInterFrameDelay = new Timer(20);
_TimerInterFrameDelay.AutoReset = false;
_TimerInterFrameDelay.Elapsed +=
new ElapsedEventHandler(EventHandler_TmrInterFrameDelay_Elapsed);
_TimerInterFrameDelay.Stop();
_TimerTimeoutCurrentTransaction = new Timer();
_TimerTimeoutCurrentTransaction.AutoReset = false;
_TimerTimeoutCurrentTransaction.Interval = 200;
_TimerTimeoutCurrentTransaction.Elapsed +=
new ElapsedEventHandler(EventHandler_TimerTimeoutCurrentTransaction_Elapsed);
_TimerTimeoutCurrentTransaction.Stop();
// Настраиваем последовательный порт
_SerialPort =
new System.IO.Ports.SerialPort("COM1", 19200, Parity.Even, 8, StopBits.One);
_SerialPort.ErrorReceived += new
SerialErrorReceivedEventHandler(EventHandler_SerialPort_ErrorReceived);
_SerialPort.DataReceived +=
new SerialDataReceivedEventHandler(EventHandler_SerialPort_DataReceived);
_SerialPort.ReceivedBytesThreshold = 1;
}
示例9: scanSkeys
void scanSkeys ()
{
if (aTimer == null)
try {
//TODO fazer animacao para findBleButton.....
if (findBleButton != null)
findBleButton.Text = "Procurando SafetyKeys";
int scanTime = 15000;
aTimer = new Timer ();
aTimer.Elapsed += aTimer_Elapsed;
aTimer.Interval = scanTime;
aTimer.Enabled = true;
if (!selMeuSkey) {
((App)Application.Current).mysafetyDll.cancelScan ();
if (App.gateSkeys != null)
App.gateSkeys.Clear ();
devices.Clear ();
}
IsBusy = true;
((App)Application.Current).mysafetyDll.scanBleDevice (scanTime);
} catch (Exception ex) {
if (findBleButton != null)
findBleButton.Text = "Procurar SafetyKeys";
IsBusy = false;
aTimer.Stop ();
aTimer = null;
Console.WriteLine ("Erro na busca por Skeys:\n\r" + ex.Message);
DependencyService.Get<IToastNotificator> ().Notify (ToastNotificationType.Error,
"MySafety", "Erro na busca por Skeys:\n\r" + ex.Message, TimeSpan.FromSeconds (3));
IsBusy = false;
}
}
示例10: Main
public static void Main(string[] args)
{
Console.Write("Loading current event status . . . ");
m_EventStatus = new EventTimerRequest().Execute().Events.ToDictionary(ev => ev.Id);
m_Data = new List<EventSpawnData>();
Console.WriteLine("Done.");
// start the timer
m_TimerSync = 0;
m_Timer = new Timer(m_PollRate.TotalMilliseconds);
m_Timer.Elapsed += WorkerThread;
m_Timer.Start();
Console.WriteLine("Beginning window analysis. Press any key to cease gathering data.");
Console.ReadKey();
Console.WriteLine();
Console.Write("Halting window analysis . . . ");
// stop timer
m_Timer.Stop();
// wait for any existing threads to complete
SpinWait.SpinUntil(() => Interlocked.CompareExchange(ref m_TimerSync, -1, 0) == 0);
Console.WriteLine("Done.");
Console.Write("Writing data to file [data.csv] . . . ");
StreamWriter sw = new StreamWriter("data.csv");
sw.WriteLine("ev_id, spawn_time, failed");
foreach (EventSpawnData data in m_Data)
sw.WriteLine("{0}, {1}, {2}", data.ev_id, data.spawn_time.ToString("G"), data.failed);
sw.Close();
}
示例11: InfiniteLoopDetector
/// <summary>
///
/// </summary>
/// <param name="Action"></param>
public static void InfiniteLoopDetector(Action Action)
{
using (var Timer = new Timer(4.0 * 1000))
{
bool Cancel = false;
Timer.Elapsed += (sender, e) =>
{
if (!Cancel)
{
Console.WriteLine("InfiniteLoop Detected! : {0}", e.SignalTime);
}
};
Timer.AutoReset = false;
Timer.Start();
try
{
Action();
}
finally
{
Cancel = true;
Timer.Enabled = false;
Timer.Stop();
}
}
}
示例12: InitializeImpl
protected override void InitializeImpl()
{
this._timers = this.TimerJobs
.Where(j => j.Item1 > 0.0)
.OrderBy(j => j.Item1)
.Select(j =>
{
Timer timer = new Timer(j.Item1);
timer.Elapsed += (sender, e) =>
{
timer.Stop();
try
{
this.Host.RequestManager.Execute<Object>(Request.Parse(j.Item2));
}
finally
{
timer.Start();
}
};
return timer;
}).ToList();
this.RunInitializingJobs();
base.InitializeImpl();
}
示例13: RoslynCodeAnalysisHelper
public RoslynCodeAnalysisHelper(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte, SVsServiceProvider serviceProvider, IVsActivityLog log)
{
_view = view;
_document = document;
_text = new Adornment();
_tasks = tasks;
_serviceProvider = serviceProvider;
_log = log;
_dispatcher = Dispatcher.CurrentDispatcher;
_adornmentLayer = view.GetAdornmentLayer(RoslynCodeAnalysisFactory.LayerName);
_view.ViewportHeightChanged += SetAdornmentLocation;
_view.ViewportWidthChanged += SetAdornmentLocation;
_text.MouseUp += (s, e) => dte.ExecuteCommand("View.ErrorList");
_timer = new Timer(750);
_timer.Elapsed += (s, e) =>
{
_timer.Stop();
System.Threading.Tasks.Task.Run(() =>
{
_dispatcher.Invoke(new Action(() => Update(false)), DispatcherPriority.ApplicationIdle, null);
});
};
_timer.Start();
}
示例14: Init
// Initialize the email server
public void Init()
{
try
{
logger.Info("Initialize in progress....");
// Priority emails send every thirty seconds and normal emails send every ten minutes
_normalEmails = new Timer(Int32.Parse(ConfigurationManager.AppSettings["NormalEmailSendTimerTick"]));
_priorityEmails = new Timer(Int32.Parse(ConfigurationManager.AppSettings["ImportantEmailSendTimerTick"]));
LoadLayouts();
// Start new threads to send the normal and important emails.
_normalEmails.Elapsed += (sender, args) =>
{
_normalEmails.Stop();
Task<bool>.Factory.StartNew(ExecuteNormalEmails);
_normalEmails.Start();
};
_priorityEmails.Elapsed += (sender, args) =>
{
_priorityEmails.Stop();
Task<bool>.Factory.StartNew(ExecuteImportantEmails);
_priorityEmails.Start();
};
logger.Info("Initialize finished.");
}
catch (Exception e)
{
logger.Error("Loading layouts", e);
ErrorDatabaseManager.AddException(e, typeof(EmailServer), additionalInformation: "RDN Email Server Service failure, Load layouts failed");
}
}
示例15: TestTimerStartAutoReset
public void TestTimerStartAutoReset()
{
CountdownEvent cde = new CountdownEvent(1);
int result = 0;
_timer = new TestTimer(1);
// Test defaults.
Assert.Equal(1, _timer.Interval);
Assert.True(_timer.AutoReset);
_timer.AutoReset = false;
_timer.Elapsed += (sender, e) => { result = ++result; cde.Signal(); };
_timer.Start();
Assert.True(_timer.Enabled);
cde.Wait();
// Only elapsed once.
Assert.Equal(1, result);
cde = new CountdownEvent(10);
_timer.AutoReset = true;
cde.Wait();
cde.Dispose();
_timer.Stop();
// Atleast elapsed 10 times.
Assert.True(result >= 10);
}