Starting a new task even if previos doesn't finished yet.
I have a simple file browser which i can open by code below:
FileBrowser.Instance.ShowDialog(FileBrowserMode.SingleFile, (results) =>
{
string path = results[0];
}
In file browser, at the end of operation i have this code:
HideDialog();
OnFinish(Results);
HideDialog():
public void HideDialog()
{
DialogCG.alpha = 0;
DialogCG.interactable = false;
DialogCG.blocksRaycasts = false;
}
OnFinish - this is a callback function which will be called after FileBrowser will finish all work and will hide itself.
Also i have a loading frame. I can make it visible by calling suitable function:
Notification.Instance.ShowLoadingAlert();
and i can hide it when i want by calling:
Notification.Instance.HideLoadingAlert();
So, my whole code in simple looks like this:
FileBrowser.Instance.ShowDialog(FileBrowserMode.SingleFile, (results) =>
{
string path = results[0];
Notifications.ShowLoadingNotification();
var bytes = File.ReadAllBytes(path);
Notifications.HideLoadingNotification();
Debug.Log("Image size: " + bytes.Length);
}
So, in my mind how it should works:
FileBrowser hidding itself.
FileBrowser calling a callback method and pass a results there.
Loading frame must be shown now.
Starting to read bytes from file. <= Here we will got a freeze but no problem.
After reading file, loading frame must be hidden.
And finally we should see a debug message.
And how it really works :
FileBrowser calling a callback method and pass a results there.
Starting to read bytes from file. <= Here we will got a freeze but no problem.
FileBrowser hidding itself.
Loading frame visible.
Loading frame hidden.
Printing a debug message.
Why order was broken and how i can keep it working in order?