Editing Documentation/Maemo For Symbian Developers Guide/Maemo and Symbian OS Concepts
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 126: | Line 126: | ||
Below you see a timeout example function with event loop (based on [http://w00d5t0ck.info/gnome_tutorial/gnome_tutorial.html#AEN53 Gnome developers' tutorial]). | Below you see a timeout example function with event loop (based on [http://w00d5t0ck.info/gnome_tutorial/gnome_tutorial.html#AEN53 Gnome developers' tutorial]). | ||
- | < | + | <code><nowiki> |
- | #include | + | #include |
- | #define COUNT_UNTIL 2 | + | #define COUNT_UNTIL 2 |
- | #define TIMEOUT 2 | + | #define TIMEOUT 2 |
- | static int counter; | + | static int counter; |
- | GMainLoop *main_loop; | + | GMainLoop *main_loop; |
- | gboolean | + | gboolean |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | int main(int argc, char *argv | + | timeout_func(gpointer data) |
- | { | + | { |
- | + | counter++; | |
- | + | g_printf("Running for the %d. time.\n", counter); | |
- | + | if (counter == COUNT_UNTIL) | |
- | + | { | |
- | + | g_main_loop_quit(main_loop); | |
- | } | + | return FALSE; |
- | </ | + | } |
+ | return TRUE; | ||
+ | } | ||
+ | |||
+ | int | ||
+ | main(int argc, char **argv) | ||
+ | { | ||
+ | counter = 0; | ||
+ | main_loop = g_main_loop_new(NULL, FALSE); | ||
+ | g_timeout_add_seconds(TIMEOUT, timeout_func, NULL); | ||
+ | g_main_loop_run(main_loop); | ||
+ | return 0; | ||
+ | } | ||
+ | </nowiki></code> | ||
In case of dealing with threads you can use: | In case of dealing with threads you can use: | ||
- | * [ | + | * [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads] (the traditional Unix-style operating system type) |
- | * | + | * GThread from GLib |
== Static data in DLLs == | == Static data in DLLs == |
Learn more about Contributing to the wiki.