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]).
-
<source lang="c">
+
<code><nowiki>
-
#include <glib.h>
+
#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 timeout_func(gpointer data)
+
gboolean
-
{
+
-
  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[])
+
timeout_func(gpointer data)
-
{
+
{
-
  counter = 0;
+
counter++;
-
  main_loop = g_main_loop_new(NULL, FALSE);
+
g_printf("Running for the %d. time.\n", counter);
-
  g_timeout_add_seconds(TIMEOUT, timeout_func, NULL);
+
if (counter == COUNT_UNTIL)
-
  g_main_loop_run(main_loop);
+
{
-
  return 0;
+
g_main_loop_quit(main_loop);
-
}
+
return FALSE;
-
</source>
+
}
 +
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:
-
* [[:wikipedia:POSIX_Threads|POSIX threads]] (the traditional Unix-style operating system type)
+
* [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads] (the traditional Unix-style operating system type)
-
* <code>GThread</code> from GLib
+
* GThread from GLib
== Static data in DLLs ==
== Static data in DLLs ==

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)