Пример #1
0
        public async Task <bool> NotifyOtherGrain(IOneWayGrain otherGrain, ISimpleGrainObserver observer)
        {
            var   task = otherGrain.Notify(observer);
            var   completedSynchronously = task.Status == TaskStatus.RanToCompletion;
            await task;

            return(completedSynchronously);
        }
Пример #2
0
        public async Task <IOneWayGrain> GetOtherGrain()
        {
            return(this.other ?? (this.other = await GetGrainOnOtherSilo()));

            async Task <IOneWayGrain> GetGrainOnOtherSilo()
            {
                while (true)
                {
                    var candidate     = this.GrainFactory.GetGrain <IOneWayGrain>(Guid.NewGuid());
                    var directorySilo = await candidate.GetPrimaryForGrain();

                    var thisSilo = await this.GetSiloAddress();

                    var candidateSilo = await candidate.GetSiloAddress();

                    if (!directorySilo.Equals(candidateSilo) &&
                        !directorySilo.Equals(thisSilo) &&
                        !candidateSilo.Equals(thisSilo))
                    {
                        return(candidate);
                    }
                }
            }
        }