Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created June 29, 2011 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCuse/1055202 to your computer and use it in GitHub Desktop.
Save AlexCuse/1055202 to your computer and use it in GitHub Desktop.
looping indexer
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