79573263

Date: 2025-04-14 13:36:39
Score: 2.5
Natty:
Report link

i've tried to get it working with searching for ProcessName

        async Task WaitForBG3()
        {
            textBox1.Text = "Searching";
            await Task.Run(async () =>
            {

                bool found = false;
                while (!found)
                {
                    Process[] ProcessList = Process.GetProcesses();
                    foreach (Process p in ProcessList)
                    {
                        if (p.ProcessName.Contains("bg3"))
                        {
                            found = true;
                        }
                    }
                }
            });
            textBox1.Text = "found and wait for Exit";
            await Task.Run(async () =>
            {
                bool running = false;
                while (!running)
                {
                    Process[] ProcessList = Process.GetProcesses();
                    foreach (Process p in ProcessList)
                    {
                        if (p.ProcessName.Contains("bg3"))
                        {
                            running = false;
                        }
                        else
                        {
                            running = true;
                        }
                    }
                }
            });
            textBox1.Text = "Exit";
        }

When i test it with Notepad, it's working as it should, but when i use the game name, it's instandly triggering the else part of the 2nd Task. Even when the game is running allready running when calling

        private async void buttonStart_Click(object sender, EventArgs e)
        {
            //LaunchViaSteam();
            await WaitForBG3();
            //do some mor stuff
        }

Any Idea why?

Reasons:
  • Blacklisted phrase (0.5): why?
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Aergernis