-
-
Save dardevelin/b1892b4bede397b6a1c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "ecere" | |
class AsyncTask : Thread | |
{ | |
public void * userData; | |
virtual bool any_object::notifyDone(); | |
void doSomething() | |
{ | |
if(!created) | |
Create(); | |
} | |
unsigned int Main() | |
{ | |
// Do something here | |
Sleep(3); | |
((GuiApplication)__thisModule.application).Lock(); | |
notifyDone(userData); | |
((GuiApplication)__thisModule.application).Unlock(); | |
return 0; | |
} | |
} | |
class Form1 : Window | |
{ | |
caption = $"Form1"; | |
background = formColor; | |
borderStyle = sizable; | |
hasMaximize = true; | |
hasMinimize = true; | |
hasClose = true; | |
clientSize = { 632, 438 }; | |
FontResource doneFont { "Arial", 24, bold = true, window = this }; | |
bool done; | |
AsyncTask task | |
{ | |
userData = this; | |
bool notifyDone() | |
{ | |
done = true; | |
Update(null); | |
return true; | |
} | |
}; | |
void OnRedraw(Surface surface) | |
{ | |
if(done) | |
{ | |
surface.font = doneFont.font; | |
surface.WriteTextf(50, 50, $"Done."); | |
} | |
} | |
Button button1 | |
{ | |
this, caption = $"Do Something", position = { 328, 136 }; | |
bool NotifyClicked(Button button, int x, int y, Modifiers mods) | |
{ | |
task.doSomething(); | |
return true; | |
} | |
}; | |
} | |
Form1 form1 {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment