Orleans: [Question] There is a way to call another Grain without waiting for the Task?

Created on 21 Jul 2019  路  6Comments  路  Source: dotnet/orleans

For example, I have to send SMS messages, and I want to just call the sending method, and without waiting for it to finish (and the result), continue to execute my code in the Grain process.
Is it possible to do?

``` cs
....
var grain1 = GrainFactory.GetGrain(1);
_ = grain1.DoSome(); //skip await
var x = 1;
.....

All 6 comments

I would NEVER skip await! You should await all tasks before method ends. I'm pretty sure you will mess up Orleans task scheduler badly if you do that and cause all kinds of problems. Instead use undocumented [OneWay] attribute. Checking out these tests will show you how to use it https://github.com/dotnet/orleans/blob/dad62cc16d4d6de671563f6b1e54196f617926a5/test/DefaultCluster.Tests/OneWayCallTests.cs

I would go for GrainFactory.GetGrain<IGrain>(1).InvokeOneWay(grain => grain.DoSome())

grain.DoSome().Ignore();

You can also to mark the DoSome method with OneWay attribute

@wanton7 @jonathansant @bluexo @ifle thank you for your answers!

There's also .Ignore() option. It is more expensive than InvokeOneWay() though because responses do get sent to the caller, logger, and ignored.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabikliot picture gabikliot  路  4Comments

scharada picture scharada  路  3Comments

Liversage picture Liversage  路  4Comments

turowicz picture turowicz  路  3Comments

pherbel picture pherbel  路  4Comments