An asynchronous sequence is similar to the seq
Posted: 13 years ago by Tomas Petricek
Async wrapper for SmtpClient (which is event-based)
15 people like thisPosted: 13 years ago by Mauricio Scheffer
Wraps an Async as an IObservable to allow easier consumption by other .NET languages. Many thanks to desco for his help: http://cs.hubfs.net/forums/thread/16545.aspx
5 people like thisPosted: 13 years ago by Ryan Riley
Simple HTTP server with Async workflow and Http Listener
11 people like thisPosted: 13 years ago by Ankur Dhama
A functional wrapper around the new WCF Web APIs (http://wcf.codeplex.com/). Composition is achieved through the use of the HttpRequestMessage -> Async
Posted: 13 years ago by Ryan Riley
A minimal TCP/IP proxy implementation with F# asynchronous workflows
24 people like thisPosted: 13 years ago by Ademar Gonzalez
An asynchronous SNTP client that can retrieve the current time from an internet time server (such as time-a.nist.gov) and optionally update the local system clock to match. Demonstrates async UDP communication, bit-shifting, and native interop/PInvoke.
13 people like thisPosted: 13 years ago by Joel Mueller
Generates a sequence using a sequence generator and Async.StartWithContinuations. This is an attempt at modeling the OWIN delegate structure in F#
6 people like thisPosted: 13 years ago by Ryan Riley
You can use this code to make a async WebRequest from Silverlight to update ViewModel.
5 people like thisPosted: 13 years ago by Tuomas Hietanen
Similar to an async { } block but captures the result for future consumption. This structure can be very useful for performing multiple result-returning operations in parallel when the results aren't needed immediately. For example, performing several read/transform operations or pre-populating a cache with yet-to-be computed values. Microsoft's Task Parallel Library in .NET 4.0 includes a Future implementation so this version is only needed on earlier .NET versions. Comments, suggestions, and improvements are always welcome.
4 people like thisPosted: 13 years ago by Jason McCampbell
Detects a mouse down then up event without a move.
4 people like thisPosted: 13 years ago by Phillip Trelford
This snippet extends several types from the System.Net namespace. It provides an easy to use API for creating asynchronous (as well as synchronous) HTTP servers using F# asynchronous workflows.
4 people like thisPosted: 13 years ago by Tomas Petricek
This snippet shows two improvements to asynchronous HTTP proxy from: http://fssnip.net/6e. First extension is to process page in chunks (instead of downloading the entire content first). The second extension is to use simple agent-based in-memory cache for previously visited pages.
7 people like thisPosted: 13 years ago by Tomas Petricek
Async is a very versatile structure, which has been used to compose CPU/IO bound computations. So it is very tempting to implement a MapReduce function based on Async and borrowing ideas from the theory of list homomorphisms.
7 people like thisPosted: 13 years ago by Nick Palladinos
This snippet demonstrates programming using asynchronous sequences. It contains (hidden) implementation of AsyncSeq type and combinators for working with it. More importantly, it demonstrates how to use asynchronous sequences to implement a simple sequential on-demand crawler.
10 people like thisPosted: 13 years ago by Tomas Petricek
The snippet uses asynchronous sequences (from F# AsyncExtensions) to download historical stock data from Yahoo. Data is downloaded in a buffered way on demand (as needed) and returned line by line. The sample then prints OHLC values for first 30 items.
6 people like thisPosted: 13 years ago by Tomas Petricek
Non-deterministic choice operation for F# asynchronous workflows - creates a workflow that returns the result of one of two asynchronous workflows, depending on which completes first. (The other workflow is not cancelled.)
4 people like thisPosted: 13 years ago by Tomas Petricek
Agent that keeps a cache of web pages that were downloaded previously. The agent handles messages to add and get data as well as message to clear the cache.
7 people like thisPosted: 13 years ago by Tomas Petricek
The snippet shows a simple F# agent that calculates average from the received values. It supports one message for adding numbers to the statistics and one for resetting the state. Moreover, the agent limits the processing rate to 1 message per second.
6 people like thisPosted: 12 years ago by Tomas Petricek
Async.Parallel2 and Async.Parallel3, for running three Async's in parallel as thread pool tasks. Alternative versions given which use Async.Parallel under the hood.
17 people like thisPosted: 12 years ago by Don Syme
TicTacToe game simulator implemented by using Joinads(http://tomasp.net/blog/joinads-async-prog.aspx). Game logic in this snippet was simplified so nicely by using Joinads. You can run this snippet on Try Joinads (http://tryjoinads.org/).
4 people like thisPosted: 12 years ago by nagat01
A set of Async primitives as described by Dave Thomas [1] (and derived from Stephen Toub [2]). [1] http://moiraesoftware.com/blog/2012/04/22/back-to-the-primitive-ii/ [2] http://blogs.msdn.com/b/pfxteam/archive/2012/02/11/10266923.aspx
2 people like thisPosted: 12 years ago by Ryan Riley
An extension of MailboxProcessor that catches all unhandled exceptions (in the body of the mailbox processor) and reports them using an event. Otherwise, the public interface is the same as for MailboxProcessor.
5 people like thisPosted: 12 years ago by Tomas Petricek
This snippet shows different options for reporting events from an F# agent. The options include triggering the event directly, using a thread pool or using a specified synchronization context.
3 people like thisPosted: 12 years ago by Tomas Petricek
just some snippets ive been using to play around with async + DNS, nothing production, updated: ipsOfDomain and domainOfIp now both return string array
2 people like thisPosted: 12 years ago by david klein
This is an implementation of the Async.Choice combinator that composes a sequence of workflows into one whose result is that of the first workflow that returns a *valid* result. You can think of it as a nondeterministic version of (Seq.tryPick id). This implementation draws ideas from Tomas Petricek's choice implementation in http://fssnip.net/6D. UPDATE (11/2015): Following the discussion in https://fslang.uservoice.com/forums/245727-f-language/suggestions/10575069-add-async-choice-to-fsharp-core I have updated the snippet.
3 people like thisPosted: 12 years ago by Eirik Tsarpalis
A simple implementation that protects the nested workflow from external cancellation. The external cancellation token is passed as an argument for cooperative cancellation. Kudos to Gian Ntzik for this one.
3 people like thisPosted: 11 years ago by Eirik Tsarpalis
A simple asynchronous workflow that retries running a given async workflow (until "resultOk" function returns true or until a specified number of retries is performed). The function uses tail-recursion in async workflows.
24 people like thisPosted: 11 years ago by Tomas Petricek
Asynchronously perform a computation until it completes or timeout is reached.
4 people like thisPosted: 11 years ago by Eirik Tsarpalis
Perform parallel Async returning heterogeneous types. (The solution presented here is based on a gist sent to me by [Anton Tayanovskyy](http://t0yv0.blogspot.com/ "Anton Tayanovskyy"), Twitter: [@t0yv0](https://twitter.com/t0yv0).)
6 people like thisPosted: 10 years ago by Jack Fox
Await a wait handle with a cancellation token and optional timeout. Returns a flag indicating whether the handle was signalled, the timeout period elapsed, or the wait was cancelled.
2 people like thisPosted: 10 years ago by Michael Parker
Extension for Async module: channel for transmitting data between subsystems, launching parallel groups of asyncs sequentially.
5 people like thisPosted: 10 years ago by dvitel
Agent demo
12 people like thisPosted: 10 years ago by Tomas Petricek
test of Async.StartWithContinuations
1 people like thisPosted: 10 years ago by omanuke
Works by forcing yourself to close Outlook and then notifies you an hour later.
4 people like thisPosted: 9 years ago by David Grenier
Joinads example from here https://github.com/tpetricek/FSharp.Joinads/blob/master/README.markdown translated to Hopac. No language extension needed, the code is equally compact and arguably more readable.
2 people like thisPosted: 9 years ago by Vasily Kirichenko
https://github.com/tpetricek/FSharp.Joinads/blob/master/src/Joins/Samples.fs#L60 ported to Hopac.
1 people like thisPosted: 9 years ago by Vasily Kirichenko
Async extensions for Socket. This extensions use SocketAsyncEventArgs, not Begin / End pattern.
2 people like thisPosted: 9 years ago by sayuri
Game evolution
0 people like thisPosted: 9 years ago by Paul Orland
F# computation expressions do not allow monadic expressions inside `finally` clauses. If we allow ourselves a bit of ugliness this can be circumvented by using a combinator. Here's an implementation for asynchronous workflows and a small application.
3 people like thisPosted: 9 years ago by Eirik Tsarpalis
Generic command/request agent with error handling used to serialise posted commands and requests which are defined by closures. Useful in serialising communications to an instrument with a C API.
1 people like thisPosted: 9 years ago by Anton Tcholakov
Helper Type Extension to convert an Async computation to IObservable.
4 people like thisPosted: 9 years ago by Riccardo Terrell
An example that showcases why AsyncBuilder.Bind() overloads for task inputs is unfit for F#
3 people like thisPosted: 8 years ago by Eirik Tsarpalis
Simple Async Workflow computation expression overload to support task operations.
3 people like thisPosted: 8 years ago by Riccardo Terrell
Provides a better implementation of Async.AwaitTask where the actual exception of a failing task is passed to the async mechanism.
12 people like thisPosted: 7 years ago by Eirik Tsarpalis
There are several maze creation algorithms (http://www.astrolog.org/labyrnth/algrithm.htm). The interesting point about Growing Tree one is that it turns into the others (for example, Recursive Backtracker and Prim's algo) when we choose the next step in different ways. Check it with tryfsharp.org.
4 people like thisPosted: 7 years ago by Natallie Baikevich
When writing asynchronous code in F#, one often needs to call methods in the .NET BCL that return Task or Task
Posted: 6 years ago by Aaron Eshbach
Async.Start with timeout in seconds
3 people like thisPosted: 6 years ago by Tuomas Hietanen
Convenient CEs that allow you to measure how long it takes to execute a given content.
5 people like thisPosted: 3 years ago by Natalie Perret
Async memory or file hashing
11 people like thisPosted: 13 years ago by Mauricio Scheffer
A basic, asynchronous TCP server
41 people like thisPosted: 13 years ago by Ryan Riley
An easy wrapper for the TPL that works nicely with (|>)
11 people like thisPosted: 13 years ago by Paul Greene
Attempt to reimplement functions AsyncRead/AsyncReadLines from 'Rx on the server ' articles (by Jeffrey van Gogh) using idea of AsyncSequence (by Tomas Petricek)
26 people like thisPosted: 13 years ago by Vladimir Matveev
The snippet demonstrates how to compose simple asynchronous functions and how to use try .. with to handle exceptions in asynchronous workflows.
35 people like thisPosted: 13 years ago by Tomas Petricek
The snippet declares a helper for creating asynchronous controllers for ASP.NET MVC 3. It declares a new base class for asynchronous actions that exposes a computation builder for writing actions using F# asynchronous workflows.
8 people like thisPosted: 13 years ago by Tomas Petricek
Async File Crawl
9 people like thisPosted: 13 years ago by fholm
The snippet overrides default AsyncControllerActionInvoker so F# async workflows can be used for ASP.NET MVC 3. It declares a new base class for asynchronous controller. Controller method has to have return type Async
Posted: 13 years ago by Dmitry Morozov
This is a simple implementation of an object pool using an agent (MailboxProcessor). The pool is created with an initial number of object using the specified generator. The ObjectPool has three functions: Put: An item can be 'Put' into the pool. Get: An item can be taken from the pool ToListAndClear: A list of all the items in the pool is returned and the pool is cleared.
9 people like thisPosted: 13 years ago by 7sharp9
Playable Tetris mini-game. Use arrow keys to move left and right and up to rotate, down to drop. Try it out in the browser on TryFSharp.org
18 people like thisPosted: 13 years ago by Phillip Trelford
An agent based scheduler, can be sent a single schedule message (ScheduleOnce) and multiple schedule message (Schedule). The schedule messages comprise of a function to receive the message, the message, an initial TimeSpan before the message is scheduled, and another timespan for the schedule repeat. Check out my blog below for more details: http://bit.ly/mK4prb
9 people like thisPosted: 13 years ago by 7sharp9
This snippet shows the implementation of three HTTP proxy servers in F#. The first is written using simple synchronous style (that isn't scalable). The second version uses event-based approach in the Node.js style, but is difficult to write. The third version uses F# async workflows and is both scalable and easy to write.
7 people like thisPosted: 13 years ago by Tomas Petricek
The snippet implements Async.Choice method that takes several workflows and creates a workflow, which returns the first result that was computed. After a workflow completes, remaining workflows are cancelled using the F# async cancellation mechanism. (The method doesn't handle exceptions.)
7 people like thisPosted: 13 years ago by Tomas Petricek
Generic batch job processor using Mail box processor. Sending quit message using PostAndReply will ensure that all jobs are completed before returning. (Exception handling is responsibility of the job)
6 people like thisPosted: 13 years ago by Ankur Dhama
An implementation of call-with-current-continuation for Async.
2 people like thisPosted: 13 years ago by Ryan Riley
Implements a simple Async.StartDisposable extension that can be used to easily create IObservable values from F# asynchronous workflows. The method starts an asynchronous workflow and returns IDisposable that cancels the workflow when disposed.
4 people like thisPosted: 13 years ago by Tomas Petricek
The name is a bit trying, but the overall callback approach greatly simplifies the mechanism for calling and handling the System.Net.Sockets.Socket Async methods.
0 people like thisPosted: 13 years ago by Ryan Riley
The dining philosophers problem implemented using a waiter.
5 people like thisPosted: 13 years ago by Alex Muscar
Pong video game runnable inside TryFSharp.org. Player 1 keys 'Q' - up, 'A' - down. Player 2 keys 'P' - up, 'L' - down.
7 people like thisPosted: 12 years ago by Phillip Trelford
Implementation of Async.Sleep in f# 2.0 doesn't allow break it execution until the time elapsed. Here is the alternate implementation which support immediate cancellation. According to discussion http://stackoverflow.com/questions/9041491/is-there-any-reason-why-async-sleep-can-not-be-canceled-immediately .
2 people like thisPosted: 12 years ago by Andrei Kolomentsev
Creating an asynchronous HTTP Server in F#.
6 people like thisPosted: 12 years ago by Julian Kay
Given a NuGet package name, this code will download the package, extract it to a temp directory, and return a sequence of FileInfo objects representing assemblies from that package, with a preference for .NET 4.5 and 4.0 assemblies, if present. Requires the "DotNetZip" package.
6 people like thisPosted: 12 years ago by Joel Mueller
Entity Framework doesn't currently support async operations, but as long as the underlying provider is System.Data.SqlClient we can make it work.
3 people like thisPosted: 12 years ago by Joel Mueller
The snippet implements Async.StartCancellable method that can be used to start a given workflow and then cancel it. The cancellation of the workflow is done asynchronously, which means that the caller will wait until the workflow is actually cancelled.
6 people like thisPosted: 12 years ago by Tomas Petricek
A simple extension method for asynchronous non-deterministic computations.
4 people like thisPosted: 12 years ago by Nick Palladinos
Code by me and Nick Palladinos.
2 people like thisPosted: 12 years ago by Eirik Tsarpalis
Allows to expose an F# async value in a C#-friendly API with the semantics of Lazy<> (compute on demand and guarantee only one computation)
3 people like thisPosted: 11 years ago by Gustavo Guerra
The snippet shows how to extend the built-in F# async computation builder with the ability to await standard .NET tasks using the let! keyword.
18 people like thisPosted: 11 years ago by Tomas Petricek
AsyncBuilder extension for maniplating some other containers directory in asynchronous workflow. Bind methods in the extension enables you to retrieve inner values of 'a IObservable and 'a IEvent by using let! or do! keyword without Async.AwaitEvent or AsyncAwaitObservable. For method in the extension omits let! binding. Yield method in the extension enables you to yield value in for expression in asynchronous workflow.
3 people like thisPosted: 11 years ago by nagat01
If you have read the awesome book by Jeffrey Richter CLR via C# 4 ed. you have discovered that there are more optimal ways for thread synchronization than the one provided by the BCL. One of them is the use of new asynchronous capabilities in order to create an asynchronous synchronization primitive. In the book it is presented an AsyncOneManyLock which is used for thread synchornization for code with a high demand for responsiveness and scalability. If you are an F# developer you know that the F# Asynchornous Workflow and the Task Parallel Library are different, so I decided to port this useful piece of code to F# and show you how to use it with an example.
0 people like thisPosted: 10 years ago by Antonio Parata
A simple computational expression to deal with asynchronous calls that return a choice type to signal failure.
Useful for calling remote services that may fail - you can call the remote service with functions of type "request -> Async
Posted: 10 years ago by mavnn
Async demo...
3 people like thisPosted: 10 years ago by Tomas Petricek
The snippet implements a simple agent that limits the number of parallelism. When created, the agent takes the maximum number of tasks it can run in parallel. When it receives a "Start" message, it will then either run the task, or store it in a queue until earlier task ha completed.
12 people like thisPosted: 10 years ago by Tomas Petricek
Implements a simple agent that lets you throttle the degree of parallelism by limiting the number of work items that are processed in parallel.
7 people like thisPosted: 10 years ago by Tomas Petricek
One of the main features of Hopac - selective synchronization using "alternatives". In this snippet we download three web pages in parallel and the one that finishes first "wins" (or the timeout alternative becomes available for picking). What's nice in this solution is that the other two downloading jobs are cancelled immediately when the winner/timeout is available (i.e. an implicitly provided to the Asyncs CancellationTokens are cancelled). Alts is highly composable and, for example, the whole Alt.choose [ ... ] thing could be nested in another Alt.choose or combined with <|> or <&> operators with another Alt and so on.
3 people like thisPosted: 9 years ago by Vasily Kirichenko
An extension of MailboxProcessor that catches all unhandled exceptions, and ensures that the user-provided function is run repeatedly until it returns normally. Based on the HandlingMailbox defined by Tomas Petricek: fssnip.net/cj
7 people like thisPosted: 9 years ago by Anthony Perez
This is a simple code implementation to copy Streams leveraging the Async workflow. After the first read, the write and read processes are done in parallel. I also used an Array of Array as buffer to avoid false sharing memory. An other improvment option could be to increase the buffer size if the copy is done in same machine.
7 people like thisPosted: 9 years ago by Riccardo Terrell
Overrides the standard Web API ApiControllerActionInvoker with one that works with controller actions return F# Async<'T> results.
5 people like thisPosted: 9 years ago by Ryan Riley
Game evolution
2 people like thisPosted: 9 years ago by Paul Orland
The 'Vsync' (AKA, 'Variable Synchronization') computation expression that coheres into the Sync comp. expr. when SYNC is #defined, and into the Async comp. expr. otherwise.
1 people like thisPosted: 9 years ago by Bryan Edds
Generic command/request agent with error handling used to serialise posted commands and requests which are defined by closures. Useful in serialising communications to an instrument with a C API.
3 people like thisPosted: 9 years ago by Anton Tcholakov
An alternative Async.RunSynchronously implementation that avoids the performance bug as recorded in https://github.com/Microsoft/visualfsharp/issues/581
2 people like thisPosted: 9 years ago by Eirik Tsarpalis
Async task computation expression, in order to avoid Async.AwaitTask for C# interop
3 people like thisPosted: 8 years ago by cboudereau
Implementation of ParallelWithThrottle to limit the number of threads created for an asynchronous Seq.map operation
8 people like thisPosted: 8 years ago by Riccardo Terrell
Related to https://github.com/Microsoft/visualfsharp/issues/2127
1 people like thisPosted: 7 years ago by Eirik Tsarpalis
Computation builder for async access.
1 people like thisPosted: 7 years ago by Zhukoff Dima
Executes Async's one by one
0 people like thisPosted: 6 years ago by Yuri Martynov
Uses SRTPs to define a general purpose adapter for awaiting arbitrary C# awaitables in F# async workflows.
3 people like thisPosted: 4 years ago by Eirik Tsarpalis
The text file containing proxies named "proxlist.txt", in the form of "ip:port" per line is the input source, the program will attempt to establish a connection through each proxy to a provided URL. Proxies that passed the test will be written out to the file "results.txt" in the form "ip:port duration_of_connection_attempt"
2 people like thisPosted: 2 years ago by Vladimir Demydov