@@ -173,146 +173,6 @@ type public ControlTests() =
173173 return is.ReadToEnd() }))
174174 " abcdefg"
175175
176- #if FX_ NO_ WINDOWSFORMS
177- #else
178- [< Test>]
179- member this.AsyncWorkerTest16() =
180-
181- let p = Path " test16 - basic worker"
182- let worker = async {
183- do p.Check 1
184- do ! Async.Sleep 400
185- do p.Check 3
186- }
187- AsyncWorker( worker) .RunAsync() |> ignore
188- System.Threading.Thread.Sleep 200
189- p.Check 2
190- System.Threading.Thread.Sleep 400
191- System.Windows.Forms.Application.DoEvents()
192- p.Check 4
193-
194- [< Test>]
195- member this.AsyncWorkerTest17() =
196- let p = Path " test17 - worker and completed event"
197- let work = async {
198- do p.Check 1
199- do ! Async.Sleep 300
200- do p.Check 3
201- return 4
202- }
203- let worker = AsyncWorker( work)
204- worker.Completed.Add( fun n -> p.Check n)
205- worker.RunAsync() |> ignore
206- System.Threading.Thread.Sleep 100
207- p.Check 2
208- System.Threading.Thread.Sleep 400
209- System.Windows.Forms.Application.DoEvents()
210- p.Check 5
211-
212- [< Test>]
213- member this.AsyncWorkerTest18() =
214- // Worker and canceled event (using group.TriggerCancel)
215- let p = Path " test18 - worker & group.TriggerCancel"
216- let work = async {
217- do p.Check 1
218- do System.Threading.Thread.Sleep 200
219- do p.Check 3
220- let! _ = async { return 1 }
221- do ()
222- }
223- let group = new System.Threading.CancellationTokenSource()
224- let worker = AsyncWorker( work, group.Token)
225- worker.Canceled.Add( fun e -> p.Check 4 )
226- worker.RunAsync() |> ignore
227- System.Threading.Thread.Sleep 100
228- p.Check 2
229- group.Cancel()
230- System.Windows.Forms.Application.DoEvents()
231- System.Threading.Thread.Sleep 500
232- System.Windows.Forms.Application.DoEvents()
233- System.Threading.Thread.Sleep 500
234- p.Check 5
235-
236- [< Test>]
237- member this.AsyncWorkerTest19() =
238- // Worker and canceled event (using worker.CancelAsync)
239- let p = Path " test19 - worker & worker.CancelAsync"
240- let work = async {
241- do p.Check 1
242- do System.Threading.Thread.Sleep 200
243- do p.Check 3
244- let! _ = async { return 1 }
245- do ()
246- }
247- let group = new System.Threading.CancellationTokenSource()
248- let worker = AsyncWorker( work)
249- worker.Canceled.Add( fun e -> p.Check 4 )
250- worker.RunAsync() |> ignore
251- System.Threading.Thread.Sleep 100
252- p.Check 2
253- worker.CancelAsync( " hello" )
254- System.Threading.Thread.Sleep 500
255- System.Windows.Forms.Application.DoEvents()
256- p.Check 5
257-
258-
259- [< Test>]
260- member this.AsyncWorkerTest20() =
261- // Worker and exceptions event
262- let p = Path " test20 - worker and exceptions"
263- let work = async {
264- do p.Check 1
265- do failwith " hello world"
266- }
267- let group = new System.Threading.CancellationTokenSource()
268- let worker = AsyncWorker( work, group.Token)
269- worker.Canceled.Add( fun _ -> p.Check - 1 )
270- worker.Completed.Add( fun _ -> p.Check - 1 )
271- worker.Error.Add( fun e -> test " test20" ( e.Message = " hello world" ); p.Check 2 )
272- worker.RunAsync() |> ignore
273- System.Threading.Thread.Sleep 50
274- System.Windows.Forms.Application.DoEvents()
275- System.Threading.Thread.Sleep 50
276- p.Check 3
277-
278- [< Test>]
279- member this.AsyncWorkerTest21() =
280- // Worker and report progress
281- let p = Path " test21 - worker & report progress"
282- let rec work = async {
283- for i in 1 .. 49 do
284- do worker.ReportProgress i
285- do printfn " report %d " i
286- do System.Threading.Thread.Sleep 1
287- }
288- and worker: AsyncWorker<_> = AsyncWorker( work)
289- worker.ProgressChanged.Add( fun n -> p.Check n)
290- worker.RunAsync() |> ignore
291- for i in 1 .. 150 do
292- System.Threading.Thread.Sleep 10
293- System.Windows.Forms.Application.DoEvents()
294- p.Check 50
295-
296- (*
297- [<Test>]
298- member this.AsyncWorkerTest21() =
299- let form = new System.Windows.Forms.Form()
300- form.Load.Add(fun _ ->
301- test16();
302- // ToDo: 7/25/2008: Disabled because of probable timing issue. QA needs to re-enable post-CTP.
303- // Tracked by bug FSharp 1.0:2891
304- //test17();
305- test18();
306- test19();
307- test20();
308- test21()
309- System.Windows.Forms.Application.Exit())
310- System.Windows.Forms.Application.Run(form)
311- // Set the synchronization context back to its original value
312- System.Threading.SynchronizationContext.SetSynchronizationContext(null);
313- *)
314-
315- #endif
316176 [< Test>]
317177 member this.AsyncResultCellTests() =
318178
0 commit comments