Skip to content

Instantly share code, notes, and snippets.

@jerstlouis
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jerstlouis/7893988e72e821706c30 to your computer and use it in GitHub Desktop.
Save jerstlouis/7893988e72e821706c30 to your computer and use it in GitHub Desktop.
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