I click on button it will start recognize and when I click button it stop

I am making speech to text app in C# window form it was working fine and running in vs but I

want to make I have add a button in my application I want to make when I click on the button it start recognizing when I clicked on the button again the recognizing will stop in C#

How can I solve this?

code here
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp5

public partial class Form1 : Form
{


    public static async Task RecognitionWithMicrophoneAsync()
    {

        var config = SpeechConfig.FromSubscription("key", "region");


        using (var recognizer = new SpeechRecognizer(config))
        {

            //Console.WriteLine("Say something...");

            var result = await recognizer.RecognizeOnceAsync().ConfigureAwait(false);

            // Checks result.
            if (result.Reason == ResultReason.RecognizedSpeech)

            {
                //Console.WriteLine($"RECOGNIZED: Text={result.Text}");
                SendKeys.SendWait(result.Text);
            }
            //else if (result.Reason == ResultReason.NoMatch)
            //{
               // Console.WriteLine($"NOMATCH: Speech could not be recognized.");
            //}
            else if (result.Reason == ResultReason.Canceled)
            {
                var cancellation = CancellationDetails.FromResult(result);
                Console.WriteLine($"CANCELED: Reason={cancellation.Reason}");

                if (cancellation.Reason == CancellationReason.Error)
                {
                    Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
                    Console.WriteLine($"CANCELED: ErrorDetails={cancellation.ErrorDetails}");
                    Console.WriteLine($"CANCELED: Did you update the subscription info?");
                }
            }
        }

    }

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        RecognitionWithMicrophoneAsync().Wait();
        //Console.WriteLine("Please press enter to exit.");
        //Console.ReadLine();
    }
}

How to convert C# console app to Winforms or other GUI?

Hey guys I managed to get some code what works fine but it uses console application

I have tried to convert it by hand and change things around to get it to work but with no avail!

I'm certain it should be simple but I may be wrong :(

Thanks guys
ignore the vb.net

If you think I'm trying to be spoon fed I can post my converted code but it doesn't work and probably 99.9% wrong

Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;

namespace ConsoleApp1

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
         private const string cKey = "key";

    private const string cRegion = "region";


    public static async Task SpeechToTextAsync()

    {

        var config = SpeechConfig.FromSubscription(cKey, cRegion);

        using (var recognizer = new SpeechRecognizer(config))

            await Recognize(recognizer);

    }

    private static async Task Recognize(SpeechRecognizer recognizer)

    {

        var result = await recognizer.RecognizeOnceAsync();


        if (result.Reason == ResultReason.RecognizedSpeech)
        {

            Console.WriteLine($"Recognized: {result.Text}");

            SendKeys.SendWait(result.Text);
        }

        else if (result.Reason == ResultReason.NoMatch)

            Console.WriteLine("Speech could not be recognized.");

        else if (result.Reason == ResultReason.Canceled)

        {

            var cancellation =

                CancellationDetails.FromResult(result);

            Console.WriteLine

                ($"Cancelled due to reason={cancellation.Reason}");

            if (cancellation.Reason == CancellationReason.Error)

            {

                Console.WriteLine

                    ($"Error code={cancellation.ErrorCode}");

                Console.WriteLine

                    ($"Error details={cancellation.ErrorDetails}");

                Console.WriteLine

                    ($"Did you update the subscription info?");

            }

        }

    }

    static void Main()

    {

        SpeechToTextAsync().Wait();
        Console.WriteLine("Please press enter to exit.");
        Console.ReadLine();

    }
}