1

I am learning F# and very interested in this language

I try to create async expression to run asynchronously.

for example

let prop1=async{ 
 for i=0 to 1000000 do ()
 MessageBox.Show("Done")
 }
let prop2=async{ 
 for i=0 to 1000000 do ()
 MessageBox.Show("Done2")
 }
Async.Start(prop1)
Async.Start(prop2)

when i run the program, i got that there are thread amount increasing of program process, from 6 to 8 , when i done close 2 message box , the process seem not destroy those created threads , the count also 8 , what happened or i got misunderstand about F# asynchronous

Thank for your help

asked Jun 14, 2011 at 13:53

2 Answers 2

2

The threads are taken from a thread pool (which is why there are more threads than actions, incidentally).

The pool exists until the application terminates.

Nothing to worry about

Edit For a nice in-depth article on F#, async and ThreadPool: http://www.voyce.com/index.php/2011/05/27/fsharp-async-plays-well-with-others/

answered Jun 14, 2011 at 13:57
Sign up to request clarification or add additional context in comments.

Comments

0

The runtime might use a thread pool, that is threads are not destroyed, but waiting for another asynchronous tasks. This technique helps the runtime reduce time to start a new async. operation, because creating a new thread might consume some time and resources.

answered Jun 14, 2011 at 13:58

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.