WPF GUI Performance with a large number of parallel tasks

后端 未结 3 509
清歌不尽
清歌不尽 2021-01-28 07:23

I developed a small client (WPF) to make some stress test on our systems. Essentially it has to call various methods on an Asp.Net WebApi endpoint in parallel.

Each time

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-28 07:52

    how can I address the problem to make everything work on a single GUI?

    Send API requests in "proper" async-await manner with only one thread.

    private async Task SendStressRequests()
    {
        var tasks = new List();
        for (int i = 0; i < 4000; i++)
        {
            var task = SendApiRequestAsync();
            tasks.Add(task);
        }
    
        await Task.WhenAll(tasks);
        // Update UI with results
    }    
    

提交回复
热议问题