コード例 #1
0
        public async Task UpdateComponentsTreeLiveInfo(IReadOnlyCollection <DeltaComponent> tree)
        {
            var flattenedTree = tree.Flatten();

            foreach (var node in flattenedTree)
            {
                switch (node.Level)
                {
                case 2:
                case 3:
                    uint data   = 5;
                    var  result = await Task.Run(() => _native.TmcDntGetLiveInfo(_cid,
                                                                                 (uint)node.Level,
                                                                                 node.TraceChain,
                                                                                 out data,
                                                                                 sizeof(uint)))
                                  .ConfigureAwait(false);

                    if (result < sizeof(uint))
                    {
                        var lastError = await Task.Run(Tms.GetLastError)
                                        .ConfigureAwait(false);

                        node.State = lastError == 120 ? DeltaComponentStates.NotSupported : DeltaComponentStates.Unknown;
                    }
                    else
                    {
                        node.State = (DeltaComponentStates)data;
                    }

                    break;

                default:
                    node.State = DeltaComponentStates.None;
                    break;
                }
            }
        }