private void Button_Click(object sender, RoutedEventArgs e)
 {
     SelectedHWND = GetSelectedAppHWND();
     if (SelectedHWND != IntPtr.Zero)
     {
         Task.Run(() =>
         {
             Image image = Screenshotter.CaptureWindow(SelectedHWND);
             OnFrameCaptured(image);
         });
     }
 }
        public void BeginCapturing()
        {
            SelectedHWND = GetSelectedAppHWND();

            Task.Run(async() =>
            {
                while (IsCapturing)
                {
                    if (SelectedHWND != IntPtr.Zero)
                    {
                        Image image = Screenshotter.CaptureWindow(SelectedHWND);
                        OnFrameCaptured(image);
                    }
                    await Task.Delay(1000 / FPS);
                }
            });
        }