Execute not blocking async shell command in C#
Execute a shell command in async in C# while not blocking the UI thread.
private async Task executeCopyCommand()
{
await Task.Run(() =>
{
var processStartInfo = new ProcessStartInfo("cmd", "/c dir")
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
var process = new Process
{
StartInfo = processStartInfo
};
process.Start();
process.WaitForExit();
});
}
Make sure that async
is present in the function definition and await
is used
in the method that calls executeCopyCommand()
.
private async void button_Click(object sender, EventArgs e)
{
await executeCopyCommand();
}
Other notes
- plan9 Compile drawterm on Fedora 38
- 10/GUI 10 Finger Multitouch User Interface
- plan9 Mount Plan9 over network
- plan9 Fix bootloader not being written in Plan9
- Add lazy loading of images in Jekyll posts
- plan9 My brand new Plan9/9front desktop
- plan9 Run 9front in Qemu
- Cronjobs on Github with Github Actions
- Aerial photography of algae spotted on river Sava
- Push to multiple origins at once in Git
- c Write and read structs to/from files in C
- Uninstall Ollama from a Linux box
- dcss Dungeon Crawl Stone Soup - New player guide
- Parse RSS feeds with Lua
- Write ISO to USB Key