Yazılım Eğitim

Yeni Haberler

C# Fixing Locking Problem When Running in C # Program (async) | Ebubekir Bastama

Good day, friends.
In this article we will tell you how to solve a frozen problem of a project with c #, with "async Programming".
If you have not read our Backgroundworker article, you can switch to my article here.
While friends tell you async, we will show you the visual using glass only through the examples and finally we will support this example with video. I will assure you already that I can understand it easily.
I'll show this example on an automation project that is already in use.
Now I say what we have to do, how will the fiction (Without fiction, we can not tell.)
  - We will be a button in our Form Application project and we will create a click event.
Now let's come to code.

        private async void simpleButton4_Click (object sender, EventArgs e)
        {
        
                await dataGet ();

        }

We added here with "async" that we did here and call our task with "await". Let's show our task now.

   async Task dataGet () // We create a new Task with async keyword ...
        {
            await Task.Run (() =>
            bgl.Tablo1 ("select id, Current, Material, Hardness, Kg, number, date from orders order by Cari asc", dataGridViewX1));
        }


"await Task.Run (() =>" next will be your code, whether you want to bring data from the database with the method or do something else it is up to you :)
I can help you if something sticks to your mind.

Contact:
WhatsApp: 05554128854
Youtube:www.youtube.com/yazilimegitim
Twitter: www.twitter.com/ebubekirbastama

Hiç yorum yok