System.Timers.Timer lifecycle

前端 未结 3 1517
深忆病人
深忆病人 2021-01-20 02:35

which is the right approach to use a System.Timers.Timer? I mean... I create the timer, set the interval and the method to be called on the Elapsed event.

do         


        
3条回答
  •  梦毁少年i
    2021-01-20 03:20

    You should call t.Stop() in the Close/Unload of your form/page or anywhere you seem fit. If you leave it running, it will utilize resources unnecessarily and also you might get exceptions while closing the application.

提交回复
热议问题