Created
June 29, 2011 22:53
-
-
Save AlexCuse/1055202 to your computer and use it in GitHub Desktop.
looping indexer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Run<'T when 'T: not struct and 'T:null and 'T:equality> (errorCallback, ct:CancellationToken, finished:ManualResetEvent) = | |
let p = QueueProvider<'T>.Create() | |
try | |
while not (ct.IsCancellationRequested) do | |
match p.Dequeue() with | |
| null -> Thread.Sleep 1000 | |
| _ as obj -> | |
try | |
write obj | |
with | ex -> | |
p.Enqueue obj | |
raise ex | |
with | ex -> | |
errorCallback ex | |
finished.Set () |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment