gdk-sharp 2.12.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. System.Object Threads

Functions for using GDK in multi-threaded programs

For thread safety, Gdk relies on the thread primitives in GLib, and on the thread-safe GLib main loop.

GLib is completely thread safe (all global data is automatically locked), but individual data structure instances are not automatically locked for performance reasons. So e.g. you must coordinate accesses to the same GHashTable from multiple threads.

Gtk# is "thread aware" but not thread safe ? it provides a global lock controlled by / which protects all use of Gtk. That is, only one thread can use Gtk at any given time.

You must call before executing any other Gtk or Gdk functions in a threaded Gtk# program.

Idles, timeouts, and input functions are executed outside of the main Gtk lock. So, if you need to call Gtk inside of such a callback, you must surround the callback with a / pair. (However, signals are still executed within the main Gtk lock.)

In particular, this means, if you are writing widgets that might be used in threaded programs, you must surround timeouts and idle functions in this matter.

As always, you must also surround any calls to Gtk not made within a signal handler with a / pair. Before calling from a thread other than your main thread, you probably want to call gdk_flush() to send all pending commands to the windowing system. (The reason you do not need to do this from the main thread is that GDK always automatically flushes pending commands when it runs out of incoming events to process and has to sleep while waiting for more events.)

A minimal main program for a threaded GTK+ application looks like: `static void Main (string[] args) { Window window; Gdk.Threads.Init (); Gtk.Application.Init (); window = new Window ("Sample"); window.Show (); Gdk.Threads.Enter (); Gtk.Application.Run (); Gdk.Threads.Leave (); return 0; }`

- Constructor
  2.12.0.0
  The default constructor.
- Method
  2.12.0.0
  System.UInt32 `` `` Priority value for handler. Idle callback. Adds an idle handler. A source id.
- Method
  2.12.0.0
  System.UInt32 `` `` `` Priority value for handler. Timeout interval. Timeout callback. Adds a timeout handler. A source id.
- Method
  2.12.0.0
  System.Void This marks the beginning of a critical section in which Gdk and Gtk functions can be called. Only one thread at a time can be in such a critial section.
- Method
  2.12.0.0
  System.Void This call must be made before any use of the main loop from Gtk#; to be safe, call it before . It must also be preceded by a call to if GLib threading has not yet been initialized. Initializes so that it can be used from multiple threads in conjunction with and .
- Method
  2.12.0.0
  System.Void Leaves a critical region begun with Gdk.Threads.Enter(). This marks the end of a critical section begun with Gdk.Threads.Enter.