当前位置: 首页>>代码示例>>C#>>正文


C# Timer.Dispose方法代码示例

本文整理汇总了C#中System.Timers.Timer.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Timer.Dispose方法的具体用法?C# Timer.Dispose怎么用?C# Timer.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Timers.Timer的用法示例。


在下文中一共展示了Timer.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScriptAssemblyCache

        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptAssemblyCache"/> class.
        /// </summary>
        ScriptAssemblyCache()
        {
            // Get the cache directory
            _cacheDir = ContentPaths.Build.Data.Join("ScriptCache");
            if (!_cacheDir.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
                !_cacheDir.EndsWith(Path.AltDirectorySeparatorChar.ToString()))
                _cacheDir += Path.DirectorySeparatorChar;

            // Ensure the directory exists
            if (!Directory.Exists(_cacheDir))
                Directory.CreateDirectory(_cacheDir);

            // Load the cache
            Load();

            // Create the saving timer
            _saveAndCleanTimer = new Timer { Interval = _autoSaveRate, AutoReset = true };
            _saveAndCleanTimer.Elapsed += _saveTimer_Elapsed;
            _saveAndCleanTimer.Start();

            // Spawn a new background timer to clean up the junk files a few seconds from now
            var cleanTimer = new Timer { Interval = 5 * 1000, AutoReset = false };
            cleanTimer.Elapsed += delegate
            {
                cleanTimer.Dispose();
                RemoveUnusedCacheFiles();
            };
            cleanTimer.Start();
        }
开发者ID:wtfcolt,项目名称:game,代码行数:32,代码来源:ScriptAssemblyCache.cs

示例2: TimersTimer

 static void TimersTimer()
 {
     System.Timers.Timer t1 = new System.Timers.Timer(1000);
     t1.AutoReset = true;
     t1.Elapsed += TimeAction;
     t1.Start();
     Thread.Sleep(10000);
     t1.Stop();
     t1.Dispose();
 }
开发者ID:ChrisChen3121,项目名称:MySourceLib,代码行数:10,代码来源:Program.cs

示例3: ProcessRequest

        public async void ProcessRequest(HttpContext context)
        {
            //validate query parameters
            QueryParams queryParams;
            try
            {
                queryParams = new QueryParams(context.Request);
            }
            catch
            {
                context.Response.StatusCode = 400; //bad request
                return;
            }

            //convert query parameters to entities            
            var ctx = new DiscCtx(ConfigManager.ConnStr);
            var reportParams = queryParams.Materialize(ctx);
            if (reportParams == null)
            {
                context.Response.StatusCode = 400;
                return;
            }

            var screenshotClient = new ReportingPhotonClient();
            var reportingTasks = screenshotClient.StartReportingActivities(reportParams.Topic,
                                                                           reportParams.Discussion,
                                                                           reportParams.Session);
            var complexReportTask = reportingTasks.Item2;

            //compute and set report parameters 
            var report = new Report
                {
                    QueryParams = queryParams,
                    ReportParams = reportParams,
                    Participants = Helpers.ParticipantsTuples(reportParams.Topic, reportParams.Session),
                    ComplexReport  = await complexReportTask,
                    ReportUrl = context.Request.Url.ToString(),
                    BaseUrl = Helpers.BaseUrl(context.Request)
                };

            var screenshotTask = reportingTasks.Item1;
            report.ReceiveScreenshots(await screenshotTask, context);

            var cleanupTimer = new Timer(10*60*1000); //10 minutes
            cleanupTimer.Elapsed += (sender, args) =>
                {
                    cleanupTimer.Dispose();
                    report.Dispose();
                    screenshotClient.Dispose();
                };   
           cleanupTimer.Start();

           context.Response.Write(report.TransformText());
        }
开发者ID:gdlprj,项目名称:duscusys,代码行数:54,代码来源:ReportingHandler.cs

示例4: OnCreated

 public void OnCreated(ILoading loading)
 {
     DestroyOld ("DistrictRCIDemand");
     var timer = new Timer (10000); //delays GUI hook so other mods such as Building Themes can do its thing
     timer.Elapsed += (object sender, ElapsedEventArgs e) => {
         HookGUI();
         timer.Enabled = false;
         timer.Dispose();
     };
     timer.Enabled = true;
 }
开发者ID:CWMlolzlz,项目名称:DistrictRCI,代码行数:11,代码来源:DistrictRCIHook.cs

示例5: Timer_Dispose_noTicksAnymore

 public void Timer_Dispose_noTicksAnymore()
 {
     global::System.Timers.Timer t = new Timer(100);
     var tc = 0;
     t.Elapsed += (s, e) => tc++;
     t.Start();
     Thread.Sleep(200);
     t.Dispose();
     Thread.Sleep(500);
     Assert.Less(tc,3);
     Assert.GreaterOrEqual(tc, 1);
 }
开发者ID:OpenSharp,项目名称:UnitWrappers,代码行数:12,代码来源:TimerTests.cs

示例6: WindowsService

        public WindowsService()
        {
            smsTimer = new Timer();
            diffTimer = new Timer();
            fullTimer = new Timer();
            registery = new RegistrySettingManager();
            sqlserverManagment = new SqlServerManagement(registery.SqlServer, registery.SqlServerInstance);

            file.AutoFlush = true;
            file.WriteLine("service newed");
            // timer for sms
            smsTimer.Interval = 12 * 60 * 60 * 1000;//har 12 saat
            smsTimer.AutoReset = true;
            smsTimer.Enabled = true;
            smsTimer.Elapsed += (x, y) => onSmsTimerElapsed();
            // timer for diff backup
            diffTimer.Interval = 60 * 1000;//har 1 daghighe
            diffTimer.AutoReset = true;
            diffTimer.Enabled = true;
            diffTimer.Elapsed += (x, y) => {
                if (registery.AutomaticBackup
                    && registery.LastDiffBackUpTime.HasValue
                    && (DateTime.Now - registery.LastDiffBackUpTime.Value).TotalHours >= registery.DiffBackUpPeriod
                    )
                onDiffTimerElapsed();
            };
            // timer for full backup
            fullTimer.Interval = 60*60*1000;//har 1 saat
            fullTimer.AutoReset = true;
            fullTimer.Enabled = true;
            fullTimer.Elapsed += (x, y) =>
            {
                if (registery.AutomaticBackup
                    && registery.LastFullBackUpTime.HasValue
                    && (DateTime.Now - registery.LastFullBackUpTime.Value).TotalDays == registery.FullBackUpPeriod
                    && DateTime.Parse(registery.FullBackUpTime).TimeOfDay >= DateTime.Now.TimeOfDay)
                    onFullTimerElapsed();
            };

            this.Disposed += (x, y) => { smsTimer.Dispose(); fullTimer.Dispose(); diffTimer.Dispose(); file.Close(); };

            //service setting
            this.ServiceName = "ShayanDentalBackUp";
            this.EventLog.Log = "Application";
            this.CanHandlePowerEvent = true;
            this.CanHandleSessionChangeEvent = true;
            this.CanPauseAndContinue = true;
            this.CanShutdown = true;
            this.CanStop = true;

            file.WriteLine("service new" + DateTime.Now);
        }
开发者ID:Ashna,项目名称:ShayanDent,代码行数:52,代码来源:WindowsService.cs

示例7: PortSelector

        public PortSelector(bool isNetworkAvailable) {
            InitializeComponent();
            DeviceRadioButton.Checked += (s, e) => ConnectCommand.RaiseCanExecuteChanged();
            NetworkRadioButton.Checked += (s, e) => ConnectCommand.RaiseCanExecuteChanged();

            if (!isNetworkAvailable) NetworkRadioButton.Visibility = NetworkControl.Visibility = Visibility.Collapsed;

            timer = new Timer {AutoReset = true, Interval = 1000};
            timer.Elapsed += timer_Elapsed;
            timer.Start();

            Closed += (s, e) => timer.Dispose();
        }
开发者ID:terasato,项目名称:Xbrt,代码行数:13,代码来源:PortSelector.xaml.cs

示例8: Delay

 public static void Delay(this Action action, int delayInMilliseconds)
 {
     var timer = new Timer
     {
         Interval = delayInMilliseconds,
         AutoReset = false
     };
     timer.Elapsed += delegate
     {
         timer.Dispose();
         action();
     };
     timer.Start();
 }
开发者ID:conradreuter,项目名称:MessageEncrypter,代码行数:14,代码来源:DelayedAction.cs

示例9: CreatePlayerAndGetId

 public int CreatePlayerAndGetId(string fileName, uint options)
 {
     if (options == 1)
     {
         var timer = new Timer(10);
         timer.Elapsed += (sender, args) =>
         {
             _eventsProvider.Publish(new PlayerCompleted() {Id = 0});
             timer.Dispose();
         };
         timer.Enabled = true;
     }
     return 0;
 }
开发者ID:sanjeevspr,项目名称:pjsip4net,代码行数:14,代码来源:MediaApiTestProvider.cs

示例10: ChannelListUpdaterService

        public ChannelListUpdaterService(IChatState chatState)
        {
            connection = chatState.Connection;
            cm = chatState.ChatModel;

            chatState.EventAggregator.GetEvent<ConnectionClosedEvent>().Subscribe(OnWipeState);

            var timer = new Timer(60*1000*1);
            timer.Elapsed += (s, e) =>
            {
                UpdateChannels();
                timer.Dispose();
            };
            timer.Start();
        }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:15,代码来源:ChannelListUpdaterService.cs

示例11: FinishTask

        private void FinishTask(ITask task)
        {
            var TaskType = task.GetType();
            var NextTime = task.NextExecutionTime();
            _TaskFactory.DestroyTask(task);

            var Timer = new Timer();
            Timer.Elapsed += (o, e) =>
                {
                    Timer.Dispose();
                    CreateTask(TaskType);
                };
            Timer.Interval = NextTime.TotalMilliseconds;
            Timer.Start();
        }
开发者ID:brsmith,项目名称:BibleOnTwitter,代码行数:15,代码来源:TaskService.cs

示例12: Main

        static void Main(string[] args)
        {
            RenderToLedSign(DateTime.Now.ToString("HH:mm"));

            m_clockTimer = new Timer();
            m_clockTimer.Interval = TimeSpan.FromSeconds(30).TotalMilliseconds;
            m_clockTimer.Elapsed += (s,e) => RenderToLedSign(DateTime.Now.ToString("HH:mm"));
            m_clockTimer.Start();

            Console.WriteLine("Press <Enter> to exit.");
            Console.ReadLine();

            m_clockTimer.Stop();
            m_clockTimer.Dispose();
        }
开发者ID:rpwjanzen,项目名称:blinken,代码行数:15,代码来源:Program.cs

示例13: OnLevelLoaded

        public void OnLevelLoaded(LoadMode mode)
        {
            if (!(mode == LoadMode.LoadGame || mode == LoadMode.NewGame)) {
                return;
            }
            Debug.Print ("OnLevelLoaded()");
            DestroyOld ("DistrictRCIDemand");
            var timer = new Timer (10000); //delays GUI hook so other mods such as Building Themes can do its thing
            timer.Elapsed += (object sender, ElapsedEventArgs e) => {
                HookGUI();
                timer.Enabled = false;
                timer.Dispose();
            };

            timer.Enabled = true;
        }
开发者ID:CWMlolzlz,项目名称:DistrictRCI,代码行数:16,代码来源:DistrictRCIHook.cs

示例14: TimedUnlock

 public static void TimedUnlock() 
 {
     if(Unlock) 
     {
         // Hook up the Elapsed event for the timer. 
         var timer = new Timer(300);
     
         timer.Elapsed += delegate(System.Object source, ElapsedEventArgs e) 
         {
             timer.Enabled = false;
             timer.Dispose();
             UnlockPolicyToolbarButton();
         };
         timer.Enabled = true;
     }
 }
开发者ID:aoighost,项目名称:BuildingThemes,代码行数:16,代码来源:PolicyPanelEnabler.cs

示例15: NotificationEventArgs

        public NotificationEventArgs(string tag, string eventName, string timestamp = "000000000000000", int delayTime = 10000)
        {
            Tag = tag;
            EventName = eventName;
            Timestamp = timestamp;

            // our timer
            var timer = new Timer {Interval = delayTime};
            // function that cálled after time elapsed
                timer.Elapsed += (sender, args) =>
                {
                    StopMeEvent?.Invoke(this, Empty);
                    timer.Stop();
                    timer.Dispose();
                };
                timer.Start();
        }
开发者ID:AlexJCarstensen,项目名称:AirTrafficMonitoring-I4SWT,代码行数:17,代码来源:NotificationEventArgs.cs


注:本文中的System.Timers.Timer.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。