Пример #1
0
    public void PrintInfo()
    {
        var description   = Future.Create(() => GetDescription());
        var numberInStock = Future.Create(() => GetInventory());

        Console.WriteLine("We have " + numberInStock.Value
                          + " copies of " + description.Value + " in stock");
    }
Пример #2
0
        public Future <Color> ParseColor(string inString)
        {
            var future = Future.Create <Color>();

            future.LinkTo(
                Routine.Start(this, ParseColorRoutine(future, inString)).ExecuteWhileDisabled()
                );
            return(future);
        }
Пример #3
0
        // This function will create a future and run a routine
        // that completes that promise asynchronously.
        public Future <string> ReverseString(string inString)
        {
            var future = Future.Create <string>();

            var routine = Routine.Start(this, ReverseStringRoutine(future, inString)).ExecuteWhileDisabled();

            // By linking the Routine to the Future, we can ensure the Future will fail
            // if the linked Routine stops unexpectedly.
            // We can also make sure the linked Routine will stop if the Future is cancelled.
            future.LinkTo(routine);
            return(future);
        }
Пример #4
0
        public static Future <ParseResult> ParseAsync(SignInfo sign, SchedulerInfo item)
        {
            var parser = new SchedulerParser(sign, item);

            return(Future.Create <ParseResult>(() => { return parser.Parse(); }));
        }