void BeginProcessButton_Click(object sender, EventArgs e)
        {
            BeginProcessButton.Enabled = false;
            AnalysingRaceLabel.Visible = true;
            State = States.CapturingGameData;

            LogListener.ToFile(workingFolderTextBox.Text + "\\capture.log");
            AwsLogListener.SetPhaseCapture();

            NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED | NativeMethods.ES_DISPLAY_REQUIRED);

            iRacingProcess = new IRacingReplay(shortTestOnly: TestOnlyCheckBox.Checked, bRecordUsingPauseResume: cb_FastVideoRecording.Checked, bCloseiRacingAfterRecording: cb_CloseiRacingAfterRecording.Checked)
                             .WithWorkingFolder(workingFolderTextBox.Text)
                             .AnalyseRace(() => { AnalysingRaceLabel.Visible = false; CapturingRaceLabel.Visible = true; })
                             .CaptureOpeningScenes()
                             .CaptureRace(overlayFileName =>
            {
                sourceVideoTextBox.Text = overlayFileName;

                LogListener.MoveToFile(Path.ChangeExtension(overlayFileName, "log"));
            })
                             .CloseIRacing()
                             .InTheBackground(errorMessage =>
            {
                workingFolderTextBox_TextChanged(null, null);
                WaitingForIRacingLabel.Visible   = false;
                AnalysingRaceLabel.Visible       = false;
                CapturingRaceLabel.Visible       = false;
                ProcessErrorMessageLabel.Visible = true;
                ProcessErrorMessageLabel.Text    = errorMessage;
                State = States.Idle;
                StateUpdated();

                LogListener.ToFile(GetDefaultLogFileName());
                AwsLogListener.SetPhaseGeneral();

                WindowState = FormWindowState.Minimized;
                Show();
                WindowState = FormWindowState.Normal;
                this.BringToFront();

                if (errorMessage == null && transcodeVideoButton.Enabled && cb_EncodeVideoAfterCapture.Checked)
                {
                    tabControl1.SelectedIndex = 1;
                    Thread.Sleep(1000);
                    TranscodeVideo_Click(null, null);
                }
                else
                {
                    NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS);
                }
            });
        }
        void TranscodeVideo_Click(object sender, EventArgs e)
        {
            State = States.Transcoding;
            SetTanscodeMessage(trancodingErrorMessage: null);

            LogListener.ToFile(Path.ChangeExtension(sourceVideoTextBox.Text, "log"));
            AwsLogListener.SetPhaseTranscode();

            NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);

            iRacingProcess = new IRacingReplay()
                             .WithEncodingOf(videoBitRate: videoBitRateNumber * 1000000)
                             .WithOverlayFile(overlayFile: sourceVideoTextBox.Text)
                             .OverlayRaceDataOntoVideo(OnTranscoderProgress, OnTranscoderCompleted, highlightVideoOnly.Checked, checkBoxShutdownAfterEncode.Checked)
                             .InTheBackground(errorMessage => {
                OnTranscoderCompleted();
                SetTanscodeMessage(trancodingErrorMessage: errorMessage);
                LogListener.ToFile(GetDefaultLogFileName());
                AwsLogListener.SetPhaseGeneral();
                NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS);
            });
        }
        async void Main_Load(object sender, EventArgs e)
        {
            changeVersionButton.Visible = File.Exists(Settings.Default.MainExecPath);

            Settings.Default.SettingChanging += Default_SettingChanging;
            iracingEvents.NewSessionData     += iracingEvents_NewSessionData;
            iracingEvents.Connected          += iracingEvents_Connected;
            iracingEvents.Disconnected       += iracingEvents_Disconnected;
            iracingEvents.StartListening();

            workingFolderTextBox.Text = Settings.Default.WorkingFolder;

            logMessagges = new LogMessages();
            Trace.Listeners.Add(new MyListener(logMessagges.TraceMessage));

            LogListener.ToFile(GetDefaultLogFileName());
            AwsLogListener.SetPhaseGeneral();

            new Task(LogSystemInformation).Start();

            fileWatchTimer          = new System.Windows.Forms.Timer();
            fileWatchTimer.Interval = 10;
            fileWatchTimer.Tick    += (s, a) => OnGameDataFileChanged();
            fileWatchTimer.Start();

            videoBitRate.Text       = Settings.Default.videoBitRate.ToString();
            sourceVideoTextBox.Text = Settings.Default.lastVideoFile;

            BeginProcessButton.Enabled = false;

            iRacingProcess = new IRacingReplay()
                             .WhenIRacingStarts(() =>
            {
                BeginProcessButton.Enabled = true;
                workingFolderTextBox_TextChanged(null, null);
                ProcessErrorMessageLabel.Visible = false;
                WaitingForIRacingLabel.Visible   = false;
            })
                             .InTheBackground(errorMessage => { });

            try
            {
                var items = await GitHubAccess.GetVersions("vipoo", "iRacingReplayDirector.net");

                var currentVersionItem    = items.FirstOrDefault(r => r.VersionStamp == AboutBox1.AssemblyVersion);
                var isNewVersionAvailable = false;

                if (currentVersionItem.VersionStamp == null)
                {
                    isNewVersionAvailable = true;
                }
                else
                {
                    var isPreRelease = currentVersionItem.Prerelease;

                    var latestVersion = items.OrderByDescending(r => new Version(r.VersionStamp)).Where(r => r.Prerelease == isPreRelease).First();
                    isNewVersionAvailable = new Version(latestVersion.VersionStamp) > AboutBox1.AssemblyVersionStamp;
                }

                if (isNewVersionAvailable)
                {
                    newVersionMessage.Visible = true;
                }
            }
            catch (Exception ee)
            {
                TraceError.WriteLine(ee.Message);
                TraceError.WriteLine(ee.StackTrace);
            }
        }