ProgressMonitorDialog : Access Violation

Frank Benoit keinfarbton at
Sat Jun 21 06:35:33 PDT 2008

Frank Benoit schrieb:
> i had tested it with dmd 1.031 ... and indeed with dmd 1.028 it crashes.
> Your first example code should work now.
> With the
>  >, true, dgIRunnableWithProgress(&run));
> there is still a problem :/

Now it works with fork=false, but another anon class workaround was 

Also a fix in the example code is needed to make fork=false work. From 
the ProgressMonitorDialog doc:
If fork is set to false, the runnable will run in the UI thread and it 
is the runnable's responsibility to call Display.readAndDispatch()  to 
ensure UI responsiveness.

The example code looks now like this:

import dwt.DWT;
import dwt.layout.FillLayout;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import dwt.widgets.Listener;
import dwt.widgets.Event;
import dwt.widgets.Button;

import dwtx.jface.dialogs.PopupDialog;
import dwt.dwthelper.utils;

import dwtx.jface.dialogs.ProgressMonitorDialog;
import dwtx.core.runtime.IProgressMonitor;
import dwtx.jface.operation.IRunnableWithProgress;

import tango.core.Thread;


void handleSelection(Event e, Shell shell) {
     void run(IProgressMonitor monitor) {
         monitor.beginTask("generate", 30);
         for(int i=0; i<100; i++) {
             if(monitor.isCanceled()) {
             version(NOFORK) Display.getCurrent().readAndDispatch();
         version(NOFORK) Display.getCurrent().readAndDispatch();
     auto dialog = new ProgressMonitorDialog(shell);
     version(NOFORK) {, true, dgIRunnableWithProgress(&run));
     } else {, true, dgIRunnableWithProgress(&run));

void main() {
     final Display display = new Display();
     final Shell shell = new Shell(display);
     shell.setLayout(new FillLayout());
     Button button = new Button(shell, DWT.PUSH);

         dgListener(&handleSelection, shell));

     while (!shell.isDisposed()) {
         if (!display.readAndDispatch()) display.sleep();

More information about the Digitalmars-d-dwt mailing list