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
- Making cgit look nicer
- vim Personal sane Vim defaults
- plan9 Install Plan9port on Linux
- plan9 My brand new Plan9/9front desktop
- 10/GUI 10 Finger Multitouch User Interface
- Change permissions of matching files recursively
- c Embedding resources into binary with C
- Convert all MKV files into other formats
- Execute not blocking async shell command in C#
- Download list of YouTube files
- Bulk thumbnails
- dcss Make DCSS playable on 4k displays
- #cat-v on weechat configuration
- Extract lines from a file with sed
- Using ffmpeg to combine videos side by side