comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet130.d @ 44:ed96ea2a2764

First swt win snippets are buiding with d2+phobos
author Frank Benoit <benoit@tionex.de>
date Wed, 25 Mar 2009 18:31:01 +0100
parents 4e5843b771cc
children 536e43f63c81
comparison
equal deleted inserted replaced
43:b98647bc0aef 44:ed96ea2a2764
30 30
31 31
32 import org.eclipse.swt.custom.BusyIndicator; 32 import org.eclipse.swt.custom.BusyIndicator;
33 33
34 import java.lang.all; 34 import java.lang.all;
35 35 import java.lang.Thread;
36 import tango.core.Thread;
37 import tango.io.Stdout;
38 import tango.util.Convert;
39 import tango.util.log.Trace;
40
41 36
42 void main(String[] args){ 37 void main(String[] args){
43 Snippet130.main(args); 38 Snippet130.main(args);
44 } 39 }
45 40
64 Thread thread = new Thread({ 59 Thread thread = new Thread({
65 id = nextId[0]++; 60 id = nextId[0]++;
66 display.syncExec(new class() Runnable { 61 display.syncExec(new class() Runnable {
67 public void run() { 62 public void run() {
68 if (text.isDisposed()) return; 63 if (text.isDisposed()) return;
69 text.append("\nStart long running task "~to!(char[])(id)); 64 text.append(Format("\nStart long running task {}", id));
70 } 65 }
71 }); // display.syncExec 66 }); // display.syncExec
72 /* 67 /*
73 * This crashes when more than 1 thread gets created. THD 68 * This crashes when more than 1 thread gets created. THD
74 for (int i = 0; i < 100000; i++) { 69 for (int i = 0; i < 100000; i++) {
75 if (display.isDisposed()) return; 70 if (display.isDisposed()) return;
76 Stdout.formatln("do task that takes a long time in a separate thread {}", id); 71 getDwtLogger().info(__FILE__, __LINE__, "do task that takes a long time in a separate thread {}", id);
77 } 72 }
78 */ 73 */
79 // This runs fine 74 // This runs fine
80 for (int i = 0; i < 6; i++) { 75 for (int i = 0; i < 6; i++) {
81 if (display.isDisposed()) return; 76 if (display.isDisposed()) return;
82 Trace.formatln("do task that takes a long time in a separate thread {} {}/6", id, i); 77 getDwtLogger().info( __FILE__, __LINE__, "do task that takes a long time in a separate thread {} {}/6", id, i);
83 Thread.sleep(0.500); 78 Thread.sleep(500);
84 } 79 }
85 80
86 if (display.isDisposed()) return; 81 if (display.isDisposed()) return;
87 display.syncExec(new class() Runnable { 82 display.syncExec(new class() Runnable {
88 public void run() { 83 public void run() {
89 if (text.isDisposed()) return; 84 if (text.isDisposed()) return;
90 text.append("\nCompleted long running task "~to!(char[])(id)); 85 text.append(Format("\nCompleted long running task {}", id));
91 } 86 }
92 }); // display.syncExec 87 }); // display.syncExec
93 done = true; 88 done = true;
94 display.wake(); 89 display.wake();
95 }); // thread = ... 90 }); // thread = ...
114 } 109 }
115 display.dispose(); 110 display.dispose();
116 } 111 }
117 private void printStart(Text text, int id ) { 112 private void printStart(Text text, int id ) {
118 if (text.isDisposed()) return; 113 if (text.isDisposed()) return;
119 Trace.formatln( "Start long running task {}", id ); 114 getDwtLogger().info( __FILE__, __LINE__, "Start long running task {}", id );
120 text.append("\nStart long running task "~to!(char[])(id)); 115 text.append(Format("\nStart long running task {}", id));
121 } 116 }
122 private void printEnd(Text text, int id ) { 117 private void printEnd(Text text, int id ) {
123 if (text.isDisposed()) return; 118 if (text.isDisposed()) return;
124 Trace.formatln( "Completed long running task {}", id ); 119 getDwtLogger().info( __FILE__, __LINE__, "Completed long running task {}", id );
125 text.append("\nCompleted long running task "~to!(char[])(id)); 120 text.append(Format("\nCompleted long running task {}", id));
126 } 121 }
127 } 122 }