From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA11811 for caml-red; Tue, 6 Feb 2001 17:47:04 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA20928 for ; Tue, 6 Feb 2001 02:23:14 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f161NCv23651 for ; Tue, 6 Feb 2001 02:23:13 +0100 (MET) Received: from localhost (mikan.kurims.kyoto-u.ac.jp [130.54.16.202]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id KAA12064; Tue, 6 Feb 2001 10:22:49 +0900 (JST) To: wester@ilt.fhg.de Cc: caml-list@inria.fr Subject: Re: LablTk problem In-Reply-To: <200102050820.JAA19345@ilt.fhg.de> References: <200102021537.QAA13795@ilt.fhg.de> <200102050820.JAA19345@ilt.fhg.de> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010206102248L.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 06 Feb 2001 10:22:48 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: weis@pauillac.inria.fr From: wester@ilt.fhg.de > Sorry it was my fault, I found the problem. I simplified things a > little bit in the above example. The program as it is works fine. > But when I was testing the program I made the following: > > Thread.start Tk.mainLoop();; > > And now the menus don't work any more. What I want to do is start > a Tk application in it's own thread and be able to draw to the canvas > interactively at the sam time. If I press one the simple buttons the > application stops, only the menus don't work. We are sorry, but ocamltk and labltk are not reentrant, so you cannot use threads with them. Having a thread running the Tk mainloop and all Tk calls and callbacks, while all other threads do some other work seems to be safe (I actually use it in the Win32 version of ocamlbrowser), but as soon as you call Tk functions in other threads you're dead. On Unix, Tcl/Tk provides two kinds of callbacks that may help you do thread-like work: timeouts (module Timer) and fileinputs (module Fileevent). They allow you to program in a non-blocking way. Unfortunately, fileinputs do not seem to work on windows. If you really want to use threads, you should look at lablgtk, which is reentrant, and allows any kind of funny thing you might want to do with threads. Jacques Garrigue --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG