Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting the example to work when you run it #2361

Merged
merged 3 commits into from
Nov 21, 2016

Conversation

voltcode
Copy link
Contributor

@voltcode voltcode commented Nov 1, 2016

actual fix proposed by @Silv3rcircl3 on Gitter today - I was merely the one to stumble on this problem

actual fix proposed by @Silv3rcircl3 on Gitter today - I was merely the one to stumble on this problem
@marcpiechura
Copy link
Contributor

@voltcode I would actually prefer the other example I posted in Gitter. It gives an better overview how you can use Source.Tick in combination with other stages. Also, since this is a console application, we should use Console.ReadLine() to block at the end.

        static void Main(string[] args)
        {
            Run();
            Console.ReadLine();
        }

        static void Run()
        {
            var oneSecond = TimeSpan.FromSeconds(1);

            using (var system = ActorSystem.Create("system"))
            using (var materializer = system.Materializer())
            {
                var source = Source.Tick(oneSecond, oneSecond, "hello");
                var flow = Flow.Create<string>()
                    .Select(s => s.ToUpper())
                    .Intersperse(", ");
                var sink = Sink.ForEach<string>(Console.WriteLine);

                var t = source.Via(flow).ToMaterialized(sink, Keep.Both).Run(Materializer);
                var cancelTickSource = t.Item1;
                var foreachTask = t.Item2;

                foreachTask = foreachTask.ContinueWith(_ => Console.WriteLine("Foreach finished"));

                cancelTickSource.CancelAfter(TimeSpan.FromSeconds(5));

                foreachTask.Wait(TimeSpan.FromSeconds(10));

                Console.WriteLine("Task finished");
            }
        }

@marcpiechura
Copy link
Contributor

@voltcode could you update this PR ?

@voltcode
Copy link
Contributor Author

Yes, sorry for the delay. I'll do it in the coming week

@alexvaluyskiy
Copy link
Contributor

@voltcode Please, update your PR

@marcpiechura
Copy link
Contributor

@voltcode thanks!

@marcpiechura marcpiechura merged commit 8b0225c into akkadotnet:dev Nov 21, 2016
@Aaronontheweb Aaronontheweb modified the milestone: 1.1.3 Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants