c# - Windows Stand Alone Application Stops Auto Refresh when moved into background -
I have a Windows standalone application that I refresh myself based on a particular user-defined interval. Everything is fine, only if the application is in the background and I have opened something else in the desktop, then the application automatically refreshes.
I am using a time for refresh. Here is the code
Global. Datetime Value will get the last refreshed value.
global.detaim = global.detime; Double minutes = Convert. ToDouble (Global.dictionary ["WebserviceIntervalMins"]. ToString ()); Date time refreshdate = global Datetime. Admins (minutes); LblRefresh.Text = refreshDate.ToString (); Public Zero InitTimer () {int interv = Convert.ToInt32 (Global.dictionary ["WebserviceIntervalMins"]. ToString ()) * 60000; Get the time interval from the // configuration file and change the timer 1 = new system in milliseconds for minutes. Window.form. Timer (); Timer 1 Tick + = new event heredollar (timer 1 post); Timer1.Interval = interv; // timer 1 in milliseconds Start (); }
Can you use something like that?
Bool Herring = true; Thread th = new thread (representative () {while (isRunning) {BeginInvoke ((action) representative () {// refresh}}; int min = convert. ToInt (Global.dictionary ["webserviceIntervalMins"]. ToString ()) ; Thread Sleep (min * 60000);}}); Th.IsBackground = True; Th.Start ();
Comments
Post a Comment