Skip to content
Paul Louth edited this page Feb 20, 2017 · 1 revision

Source

tell is used to send a message from one process to another (or from outside a process to a process).

The messages are sent to the process asynchronously and join the process' inbox. The process will deal with one message from its inbox at a time. It cannot start the next message until it's finished with a previous message.

Example 1

    using LanguageExt;
    using LanguageExt.UnitsOfMeasure;
    using static LanguageExt.Prelude;
    using static LanguageExt.Process;
    ...

    var pid = spawn<string>("hw", msg => Console.WriteLine(msg));

    // Sends the 'hello, world' message to the 'hw' Process
    tell(pid, "hello, world");

    // Sends the 'goodbye, world' message to the 'hw' Process in 5 seconds time
    tell(pid, "goodbye, world", 5*sec);

Example 2

    using LanguageExt;
    using LanguageExt.UnitsOfMeasure;
    using static LanguageExt.Prelude;
    using static LanguageExt.Process;
    ...

    // Log process
    var logger = spawn<string>("logger", Console.WriteLine);

    // Ping process
    ping = spawn<string>("ping", msg =>
    {
        tell(logger, msg);
        tell(pong, "ping", 100*ms);
    });

    // Pong process
    pong = spawn<string>("pong", msg =>
    {
        tell(logger, msg);
        tell(ping, "pong", 100*ms);
    });

    // Trigger
    tell(pong, "start");

Source