void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            
            TimeDiff += (DateTime.Now - _lastTime).TotalMilliseconds - (1000*Resolution);
            _lastTime = DateTime.Now;

            if (!IsActive)
            {
                IsActive = CheckStart();
                if (IsActive)
                    _firstLapseStartTime = DateTime.Now;
            }
            RaisePropertyChanged(() => StatusText);
            if (!IsActive)
                return;
            if (IsActive)
            {
                if (Math.Round((DateTime.Now - _lastCaptureTime).TotalSeconds) >= TimeBetweenShots || (FullSpeed && !ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy))
                {
                    _lastCaptureTime = DateTime.Now;
                    _totalCaptures++;
                    try
                    {
                        if (Capture)
                        {
                            if (Bracketing)
                            {
                                if (_bracketingViewModel == null)
                                    _bracketingViewModel = new BracketingViewModel();
                                Task.Factory.StartNew(new Action(_bracketingViewModel.Start));
                                StaticHelper.Instance.SystemMessage = _bracketingViewModel.Error;
                            }
                            else
                            {
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.Capture);                                
                            }
                        }
                        if (CaptureAll)
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.CaptureAll);
                        if (CaptureScript)
                        {
                            if (Path.GetExtension(ScriptFile.ToLower()) == ".tcl")
                            {
                                try
                                {
                                    var manager = new TclScripManager();
                                    manager.Execute(File.ReadAllText(ScriptFile));
                                }
                                catch (Exception exception)
                                {
                                    Log.Error("Script error", exception);
                                    StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                                }
                            }
                            else
                            {
                                var script = ServiceProvider.ScriptManager.Load(ScriptFile);
                                script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                                ServiceProvider.ScriptManager.Execute(script);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Timelapse error ", exception);
                        StaticHelper.Instance.SystemMessage = "Capture error";
                    }
                }
                if (CheckStop())
                {
                    IsActive = false;
                    if (!StartDaily)
                    {
                        IsRunning = false;
                        _timer.Stop();
                    }
                }
            }
        }
        private void CheckForUpdate()
        {
            var scriptFile = ServiceProvider.Settings.StartupScript;
            if (scriptFile != null && File.Exists(scriptFile))
            {
                if (Path.GetExtension(scriptFile.ToLower()) == ".tcl")
                {
                    try
                    {
                        var manager = new TclScripManager();
                        manager.Execute(File.ReadAllText(scriptFile));
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Script error", exception);
                        StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                    }
                }
                else
                {
                    var script = ServiceProvider.ScriptManager.Load(scriptFile);
                    script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                    ServiceProvider.ScriptManager.Execute(script);
                }
            }
            if ((DateTime.Now - ServiceProvider.Settings.LastUpdateCheckDate).TotalDays > 7)
            {
                if (!ServiceProvider.Branding.CheckForUpdate)
                    return;

                Thread.Sleep(2000);
                ServiceProvider.Settings.LastUpdateCheckDate = DateTime.Now;
                ServiceProvider.Settings.Save();
                Dispatcher.Invoke(new Action(() => NewVersionWnd.CheckForUpdate(false)));
            }
            else
            {
                if (!ServiceProvider.Branding.ShowWelcomeScreen || !ServiceProvider.Branding.OnlineReference)
                    return;

                // show welcome screen only if not start minimized
                if (!ServiceProvider.Settings.StartMinimized)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        try
                        {
                            var wnd = new Welcome();
                            wnd.ShowDialog();
                        }
                        catch
                        {
                        }
                    }));
                }
            }
        }