示例#1
0
 public IAsyncOperation <DepthFrameReader> OpenDepthFrameReaderAsync()
 {
     return(Task.Run(async() =>
     {
         if (DepthReader == null)
         {
             if (Type == SensorType.NetworkClient)
             {
                 DepthReader = new DepthFrameReader(this, _networkClient);
             }
             else
             {
                 var depthSourceInfo = _sourceGroup.SourceInfos.FirstOrDefault(si => si.SourceKind == MediaFrameSourceKind.Depth);
                 if (depthSourceInfo != null)
                 {
                     MediaFrameSource depthSource;
                     if (_mediaCapture.FrameSources.TryGetValue(depthSourceInfo.Id, out depthSource))
                     {
                         var depthMediaReader = await _mediaCapture.CreateFrameReaderAsync(depthSource);
                         DepthReader = new DepthFrameReader(this, depthMediaReader);
                     }
                 }
             }
         }
         await DepthReader?.OpenAsync();
         return DepthReader;
     }).AsAsyncOperation());
 }
示例#2
0
        public IAsyncAction CloseAsync()
        {
            return(Task.Run(async() =>
            {
                await BodyIndexReader?.CloseAsync();
                BodyIndexReader?.Dispose();
                BodyIndexReader = null;

                await BodyReader?.CloseAsync();
                BodyReader?.Dispose();
                BodyReader = null;

                await ColorReader?.CloseAsync();
                ColorReader?.Dispose();
                ColorReader = null;

                await DepthReader?.CloseAsync();
                DepthReader?.Dispose();
                DepthReader = null;

                AudioReader?.Close();
                AudioReader?.Dispose();
                AudioReader = null;

                _mediaCapture?.Dispose();
                _mediaCapture = null;

                _networkClient?.CloseConnection();
                _networkClient = null;

                _networkServer?.CloseConnection();
                _networkServer = null;
            }).AsAsyncAction());
        }