[previous] [up] [next]     [index]
Next: Exceptions and Continuation Jumps Up: Event Dispatching and Eventspaces Previous: Eventspaces and Threads

Creating and Setting the Eventspace

Whenever a frame, dialog, or timer is created, it is associated with the eventspace specified by the current-eventspace parameter (see parameters). When the current-eventspace procedure is called with no arguments, it returns the current eventspace value. When current-eventspace is called with an eventspace value, it changes the current eventspace to the provided one.

The make-eventspace procedure creates a new eventspace. The following example creates a new eventspace and a new frame in the eventspace (the parameterize syntactic form temporary sets a parameter value):

  (let ([new-es (make-eventspace)]) 
    (parameterize ([current-eventspace new-es]) 
      (make-object frame% "Example"))) 

When an eventspace is created, it is placed under the management of the current custodian (see parameters). When a custodian shuts down an eventspace, all frames and dialogs associated with the eventspace are destroyed (without calling can-close? or on-close in top-level-window<%>), all timers in the eventspace are stopped, and all enqueued callbacks are removed. Attempting to create a new window, timer, or explicitly queued event in a shut-down eventspace raises the exn:misc exception.



PLT