Answer the question
In order to leave comments, you need to log in
How to notify the user that a deletion is currently in progress?
Help me please. I cannot block the form and buttons while deleting the folder and at the same time change the cursor from Arrow to Wait.
Delete with Directory.Delete("Путь каталога", true);
Tried like this
this.Cursor = Cursors.Wait;
Directory.Delete("Путь каталога", true);
but it changes the cursor after deletion, and it is necessary before deletion. Please help me how to do it.
Answer the question
In order to leave comments, you need to log in
It suggests itself:
If the delete operation is quite long in time, then it would be worthwhile to perform it in another thread (not in the "UI thread"):
var bw = new BackgroundWorker();
bw.DoWork += (o, eo) =>
{
Directory.Delete("Путь каталога", true);
};
bw.RunWorkerCompleted += (o, eo) =>
{
IsEnabled = true;
Mouse.OverrideCursor = Cursors.Arrow;
};
IsEnabled = false;
Mouse.OverrideCursor = Cursors.Wait;
bw.RunWorkerAsync();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question