当前位置: 首页>>代码示例>>C#>>正文


C# IEnumerator.Dispose方法代码示例

本文整理汇总了C#中IEnumerator.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerator.Dispose方法的具体用法?C# IEnumerator.Dispose怎么用?C# IEnumerator.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEnumerator的用法示例。


在下文中一共展示了IEnumerator.Dispose方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: H264Bitstream

        public H264Bitstream(IEnumerable<byte> buffer)
        {
            _bytes = buffer.GetEnumerator();

            if (!_bytes.MoveNext())
            {
                _bytes.Dispose();
                _bytes = null;

                return;
            }

            _nextByte = _bytes.Current;

            _bitsLeft = 0;
        }
开发者ID:henricj,项目名称:phonesm,代码行数:16,代码来源:H264Bitstream.cs

示例2: ReceiveFromEndpoint

		public void ReceiveFromEndpoint()
		{
			try
			{
				if (_log.IsDebugEnabled)
					_log.DebugFormat("Calling Receive on {0} from thread {1} ({2})", _bus.Endpoint.Address.Uri,
						Thread.CurrentThread.ManagedThreadId, _receiveTimeout);

				_startTime = SystemUtil.UtcNow;
				_receiveTime.Start();

				_bus.Endpoint.Receive(context =>
					{
						if (_log.IsDebugEnabled)
							_log.DebugFormat("Enumerating pipeline on {0} from thread {1}", _bus.Endpoint.Address.Uri,
								Thread.CurrentThread.ManagedThreadId);

						context.SetBus(_bus);
						
						IEnumerable<Action<IConsumeContext>> enumerable = _bus.InboundPipeline.Enumerate(context);

						_consumers = enumerable.GetEnumerator();
						if (!_consumers.MoveNext())
						{
							_consumers.Dispose();
							return null;
						}

						return DeliverMessageToConsumers;
					}, _receiveTimeout);
			}
			catch (ObjectDisposedException)
			{
				Thread.Sleep(1000);
			}
			catch (Exception ex)
			{
				_log.Error("Consumer Exception Exposed", ex);
			}
			finally
			{
				NotifyReceiveCompleted();
				NotifyConsumeCompleted();
			}
		}
开发者ID:codeyu,项目名称:MassTransit,代码行数:45,代码来源:ServiceBusReceiveContext.cs

示例3: deleteExpiredSentItemsButton_Click

        private void deleteExpiredSentItemsButton_Click(object sender, RibbonControlEventArgs e)
        {
            var expiredSentItems = new ExpiredSentItems();

            // Setup the progress dialog.
            m_progressDialog = new ProgressDialog { WindowTitle = DefaultWindowTitle, LabelContent = "Deleting..." };
            m_progressDialog.Canceled += progressDialog_Canceled;
            m_progressDialog.Maximum = expiredSentItems.Count;

            // this sets up an enumeration to give us one Outlook item at a time in reverse order--suitable for deleting
            m_expiredMailItems = expiredSentItems.GetEnumerator();

            // Start the deleting and show the progress dialog
            DeleteMailItem();
            m_progressDialog.ShowDialog();
            if (m_expiredMailItems != null) // not canceled
                m_expiredMailItems.Dispose();
        }
开发者ID:JDanielSmith,项目名称:Projects,代码行数:18,代码来源:ExplorerRibbon.cs

示例4: WriteDataAsync

 void WriteDataAsync(ISocket socket, IEnumerator<byte[]> ds)
 {
     if (ds.MoveNext())
     {
         Debug.WriteLine("Client writing data async.");
         if (!socket.Write(new ArraySegment<byte>(ds.Current), () => WriteDataAsync(socket, ds)))
             WriteDataAsync(socket, ds);
     }
     else
     {
         Debug.WriteLine("Client ending connection.");
         ds.Dispose();
         socket.End();
     }
 }
开发者ID:reider-roque,项目名称:Elpis,代码行数:15,代码来源:NetTests.cs

示例5: default

            void IAsyncStateMachine.MoveNext()
            {
                int result = default(int);
                try
                {
                    bool doFinallyBodies = true;
                    switch (state)
                    {
                        case -3:
                            goto Done;
                        case 0:
                            goto FirstAwaitContinuation;
                        case 1:
                            goto SecondAwaitContinuation;
                    }
                    // Default case - first call (state is -1)
                    total = 0;
                    iterator = text.GetEnumerator();

                // We really want to jump straight to FirstAwaitRealContinuation, but we can't
                // goto a label inside a try block...
                FirstAwaitContinuation:
                    // foreach loop
                    try
                    {
                        // for/foreach loops typically have the condition at the end of the generated code.
                        // We want to go there *unless* we're trying to reach the first continuation.
                        if (state != 0)
                        {
                            goto LoopCondition;
                        }
                        goto FirstAwaitRealContinuation;
                    LoopBody:
                        ch = iterator.Current;
                        unicode = ch;
                        TaskAwaiter localTaskAwaiter = Task.Delay(unicode).GetAwaiter();
                        if (localTaskAwaiter.IsCompleted)
                        {
                            goto FirstAwaitCompletion;
                        }
                        state = 0;
                        taskAwaiter = localTaskAwaiter;
                        builder.AwaitUnsafeOnCompleted(ref localTaskAwaiter, ref this);
                        doFinallyBodies = false;
                        return;
                    FirstAwaitRealContinuation:
                        localTaskAwaiter = taskAwaiter;
                        taskAwaiter = default(TaskAwaiter);
                        state = -1;
                    FirstAwaitCompletion:
                        localTaskAwaiter.GetResult();
                        localTaskAwaiter = default(TaskAwaiter);
                        total += unicode;
                    LoopCondition:
                        if (iterator.MoveNext())
                        {
                            goto LoopBody;
                        }
                    }
                    finally
                    {
                        if (doFinallyBodies && iterator != null)
                        {
                            iterator.Dispose();
                        }
                    }

                    // After the loop
                    YieldAwaitable.YieldAwaiter localYieldAwaiter = Task.Yield().GetAwaiter();
                    if (localYieldAwaiter.IsCompleted)
                    {
                        goto SecondAwaitCompletion;
                    }
                    state = 1;
                    yieldAwaiter = localYieldAwaiter;
                    builder.AwaitUnsafeOnCompleted(ref localYieldAwaiter, ref this);
                    doFinallyBodies = false;
                    return;

                SecondAwaitContinuation:
                    localYieldAwaiter = yieldAwaiter;
                    yieldAwaiter = default(YieldAwaitable.YieldAwaiter);
                    state = -1;
                    SecondAwaitCompletion:
                    localYieldAwaiter.GetResult();
                    localYieldAwaiter = default(YieldAwaitable.YieldAwaiter);
                    result = total;
                }
                catch (Exception ex)
                {
                    state = -2;
                    builder.SetException(ex);
                    return;
                }
                Done:
                state = -2;
                builder.SetResult(result);
            }
开发者ID:Narekmarg,项目名称:RAU-OS-Labs,代码行数:98,代码来源:DecompilationSampleDecompiled.cs

示例6: GenerationIndices

        void IGenerationScheme.Generate(System3 system, DateTime simulationTime, long simulationStep)
        {
            var trailBundleSize = Math.Max (system.SimulationScheme is ParticlesWithTrails ? ((ParticlesWithTrails)system.SimulationScheme).TrailBundleSize : 1, 1);
            var dt = (float)system.DT;

            m_GIndices = m_GIndices ?? GenerationIndices(system).GetEnumerator();
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            while(m_GIndices.MoveNext())
            {
                var pack = m_GIndices.Current;
                var i = (int)(pack >> 32);
                var j = (int)(pack);

                var ii = i + j * trailBundleSize;
                if (ii >= system.Position.Length) {
                    break;
                }

                var _i = i;
                var metai = system.Meta.MapReadWrite(ref _i);
                if(j == 0)
                {
                    if (m_Length != system.Position.Length)
                    {
                        system.ParticleGenerator.NewBundle (system, i);
                    }
                    else if (metai[_i].LifeLen <= 0) {
                        system.ParticleGenerator.NewBundle (system, i);
                    }
                    else
                    {
                        metai[_i].LifeLen--;
                        metai[_i].Size = Math.Max (system.ParticleGenerator.UpdateSize (system, i, i), float.Epsilon);
                    }
                }
                else
                {
                    var _ii = ii;
                    system.Meta.MapReadWrite(ref _ii)[_ii].Size = Math.Max (system.ParticleGenerator.UpdateSize (system, i, ii), float.Epsilon);
                }

                if(m_Length == system.Position.Length)
                    if(sw.Elapsed > TimeSpan.FromMilliseconds(50))
                        return;
            }

            m_GIndices.Dispose ();
            m_GIndices = null;
            m_Length = system.Position.Length;
        }
开发者ID:smalld,项目名称:particle_system,代码行数:52,代码来源:GenerationSchemes.cs

示例7: MoveNext

 /// <summary>
 /// Moves to the next feature.
 /// </summary>
 /// <returns></returns>
 public bool MoveNext()
 {
     if(_currentEnumerator != null &&
         _currentEnumerator.MoveNext())
     { // there is still a current enumerator.
         _current = _currentEnumerator.Current;
         return true;
     }
     _currentEnumerator = null;
     while(_source.MoveNext())
     {
         var features = _interpreter.Interpret(_source.Current());
         if (features != null)
         { // an object was succesfully converted.
             _currentEnumerator = features.GetEnumerator();
             if(_currentEnumerator.MoveNext())
             { // move to first object in feature collection.
                 _current = _currentEnumerator.Current;
                 return true;
             }
             else
             { // an empty feature collection, try next one.
                 _currentEnumerator.Dispose();
                 _currentEnumerator = null;
             }
         }
     }
     return false;
 }
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:33,代码来源:OsmFeatureStreamSource.cs

示例8: ReceiveFromEndpoint

		/// <summary>
		/// <para>Performs a receive from the endpoint that is specified on the bus given in the 
		/// constructor. First try to do the receive, then let the endpoint/transport
		/// call <see cref="DeliverMessageToConsumers"/> (if there are consumers interested)</para>
		/// <para>This method must not throw exceptions, because it might not be run on the main thread.</para>
		/// </summary>
		public void ReceiveFromEndpoint()
		{
			try
			{
				_startTime = SystemUtil.UtcNow;
				_receiveTime.Start();

				// Let the endpoint (and hence inbound transport) consume a message.
				// This lambda passed is not called until the transport decides that it has
				// gotten a message and want to pass it forward.
				_bus.Endpoint.Receive(context =>
					{
						context.SetBus(_bus);
						
						// look inside the inbound pipeline and find all message sinks that match the receive
						// context (i.e. the message type we actually got from the transport)
						// Have a look at everything implementing IPipelineSink<IConsumeContext> to
						// dig deeper
						IEnumerable<Action<IConsumeContext>> enumerable = _bus.InboundPipeline.Enumerate(context);

						_consumers = enumerable.GetEnumerator();
						if (!_consumers.MoveNext())
						{
							// meaning we don't have any sinks interested in this msg context
							_consumers.Dispose();
							return null; 
						}

						// otherwise, we have some consumers
						return DeliverMessageToConsumers;
					}, _receiveTimeout);
			}
			catch (ObjectDisposedException ex)
			{
				_log.Warn("Endpoint threw ObjectDisposedException", ex);
				Thread.Sleep(1000);
			}
			catch (Exception ex)
			{
				_log.Error("Consumer Exception Exposed", ex);
			}
			finally
			{
				NotifyReceiveCompleted();
				NotifyConsumeCompleted();
			}
		}
开发者ID:rajwilkhu,项目名称:MassTransit,代码行数:53,代码来源:ServiceBusReceiveContext.cs

示例9: RunAsyncProd

        void RunAsyncProd(IDataConsumer consumer, IEnumerator<ArraySegment<byte>> data)
        {
            while (true)
            {
                if (!data.MoveNext())
                {
                    consumer.OnEnd();
                    data.Dispose();
                    break;
                }

                if (consumer.OnData(data.Current, () => RunAsyncProd(consumer, data)))
                    break;
            }
        }
开发者ID:ruxo,项目名称:kayak,代码行数:15,代码来源:OutputSegmentQueueTests.cs

示例10: Parse

        public void Parse()
        {
            _sourceEnumerator = Source
                .Where(t => TokenType.ToIgnore.NotContains(t.Type))
                .GetEnumerator();

            Match(TokenType.Undefined);
            while (_inputToken.Type != TokenType.Eop)
            {
                if (_inputToken.Type == TokenType.String)
                {
                    MethodBody
                        .Ldloc("sw")
                        .Ldstr(((Token<string>)_inputToken).Value)
                        .Callvirt<TextWriter>("Write", typeof(string));

                    Match(TokenType.String);
                }

                else if (_inputToken.Type == TokenType.GetShortHand)
                {
                    MethodBody.Ldloc("sw");
                    RetrieveVariableValue(((GetShorhandToken) _inputToken).Identifier);
                    MethodBody.Callvirt<TextWriter>("Write", _resultType);
                    Match(TokenType.GetShortHand);
                }

                else
                {
                    Match(TokenType.BeginExpressionMarker);
                    MethodBody.Ldloc("sw");
                    Expression();
                    if (_resultType == null)
                    {
                        MethodBody.Pop();
                    }
                    else
                    {
                        MethodBody.Callvirt<TextWriter>("Write", _resultType);
                    }

                    Match(TokenType.EndExpressionMarker);
                }
            }

            Match(TokenType.Eop);

            MethodBody
                .Ldloc("sw")
                .Callvirt<TextWriter>("Flush");


            //Emitter.Eop();

            _sourceEnumerator.Dispose();
        }
开发者ID:ElemarJR,项目名称:Jujubas,代码行数:56,代码来源:ExpressionParser.cs

示例11: WriteNext

        static void WriteNext(IEnumerator<string> data, IDataConsumer c, bool sync)
        {
            while (true)
            {
                if (!data.MoveNext())
                {
                    c.OnEnd();
                    data.Dispose();
                    break;
                }

                var seg = new ArraySegment<byte>(Encoding.UTF8.GetBytes(data.Current));
                if (sync)
                {
                    if (c.OnData(seg, null))
                        throw new Exception("sync write should have returned false");
                }
                else
                    if (c.OnData(
                        seg,
                        () => WriteNext(data, c, sync)))
                        break;
            }
        }
开发者ID:edazdarevic,项目名称:kayak,代码行数:24,代码来源:Mocks.cs


注:本文中的IEnumerator.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。