C# 正在查找.NET4.5进度源代码

C# 正在查找.NET4.5进度源代码,c#,.net-4.5,C#,.net 4.5,我没有安装.NET4.5,也无法安装它 在哪里可以找到新System.Progress类的源代码 或者有人在安装了.NET 4.5 beta版的情况下复制/粘贴代码下载.NET Framework 4.5版并将其安装到您的PC上。然后获取一份类似dotPeek的副本,并使用该副本查看源代码的进度 下载.NET Framework 4.5版并将其安装到您的PC上。然后获取一份类似dotPeek的副本,并使用该副本查看源代码以了解进度 以下是ILSpy的输出: using System; using

我没有安装.NET4.5,也无法安装它

在哪里可以找到新System.Progress类的源代码

或者有人在安装了.NET 4.5 beta版的情况下复制/粘贴代码

下载.NET Framework 4.5版并将其安装到您的PC上。然后获取一份类似dotPeek的副本,并使用该副本查看源代码的进度

下载.NET Framework 4.5版并将其安装到您的PC上。然后获取一份类似dotPeek的副本,并使用该副本查看源代码以了解进度


以下是ILSpy的输出:

using System;
using System.Runtime;
using System.Threading;
namespace System
{
    [__DynamicallyInvokable]
    public class Progress<T> : IProgress<T>
    {
        private readonly SynchronizationContext m_synchronizationContext;
        private readonly Action<T> m_handler;
        private readonly SendOrPostCallback m_invokeHandlers;
        [__DynamicallyInvokable]
        public event EventHandler<T> ProgressChanged
        {
            [__DynamicallyInvokable]
            add
            {
                EventHandler<T> eventHandler = this.ProgressChanged;
                EventHandler<T> eventHandler2;
                do
                {
                    eventHandler2 = eventHandler;
                    EventHandler<T> value2 = (EventHandler<T>)Delegate.Combine(eventHandler2, value);
                    eventHandler = Interlocked.CompareExchange<EventHandler<T>>(ref this.ProgressChanged, value2, eventHandler2);
                }
                while (eventHandler != eventHandler2);
            }
            [__DynamicallyInvokable]
            remove
            {
                EventHandler<T> eventHandler = this.ProgressChanged;
                EventHandler<T> eventHandler2;
                do
                {
                    eventHandler2 = eventHandler;
                    EventHandler<T> value2 = (EventHandler<T>)Delegate.Remove(eventHandler2, value);
                    eventHandler = Interlocked.CompareExchange<EventHandler<T>>(ref this.ProgressChanged, value2, eventHandler2);
                }
                while (eventHandler != eventHandler2);
            }
        }
        [__DynamicallyInvokable]
        public Progress()
        {
            this.m_synchronizationContext = (SynchronizationContext.CurrentNoFlow ?? ProgressStatics.DefaultContext);
            this.m_invokeHandlers = new SendOrPostCallback(this.InvokeHandlers);
        }
        [__DynamicallyInvokable]
        public Progress(Action<T> handler) : this()
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            this.m_handler = handler;
        }
        [__DynamicallyInvokable]
        protected virtual void OnReport(T value)
        {
            Action<T> handler = this.m_handler;
            EventHandler<T> progressChanged = this.ProgressChanged;
            if (handler != null || progressChanged != null)
            {
                this.m_synchronizationContext.Post(this.m_invokeHandlers, value);
            }
        }
        [__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        void IProgress<T>.Report(T value)
        {
            this.OnReport(value);
        }
        private void InvokeHandlers(object state)
        {
            T t = (T)((object)state);
            Action<T> handler = this.m_handler;
            EventHandler<T> progressChanged = this.ProgressChanged;
            if (handler != null)
            {
                handler(t);
            }
            if (progressChanged != null)
            {
                progressChanged(this, t);
            }
        }
    }
}

以下是ILSpy的输出:

using System;
using System.Runtime;
using System.Threading;
namespace System
{
    [__DynamicallyInvokable]
    public class Progress<T> : IProgress<T>
    {
        private readonly SynchronizationContext m_synchronizationContext;
        private readonly Action<T> m_handler;
        private readonly SendOrPostCallback m_invokeHandlers;
        [__DynamicallyInvokable]
        public event EventHandler<T> ProgressChanged
        {
            [__DynamicallyInvokable]
            add
            {
                EventHandler<T> eventHandler = this.ProgressChanged;
                EventHandler<T> eventHandler2;
                do
                {
                    eventHandler2 = eventHandler;
                    EventHandler<T> value2 = (EventHandler<T>)Delegate.Combine(eventHandler2, value);
                    eventHandler = Interlocked.CompareExchange<EventHandler<T>>(ref this.ProgressChanged, value2, eventHandler2);
                }
                while (eventHandler != eventHandler2);
            }
            [__DynamicallyInvokable]
            remove
            {
                EventHandler<T> eventHandler = this.ProgressChanged;
                EventHandler<T> eventHandler2;
                do
                {
                    eventHandler2 = eventHandler;
                    EventHandler<T> value2 = (EventHandler<T>)Delegate.Remove(eventHandler2, value);
                    eventHandler = Interlocked.CompareExchange<EventHandler<T>>(ref this.ProgressChanged, value2, eventHandler2);
                }
                while (eventHandler != eventHandler2);
            }
        }
        [__DynamicallyInvokable]
        public Progress()
        {
            this.m_synchronizationContext = (SynchronizationContext.CurrentNoFlow ?? ProgressStatics.DefaultContext);
            this.m_invokeHandlers = new SendOrPostCallback(this.InvokeHandlers);
        }
        [__DynamicallyInvokable]
        public Progress(Action<T> handler) : this()
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            this.m_handler = handler;
        }
        [__DynamicallyInvokable]
        protected virtual void OnReport(T value)
        {
            Action<T> handler = this.m_handler;
            EventHandler<T> progressChanged = this.ProgressChanged;
            if (handler != null || progressChanged != null)
            {
                this.m_synchronizationContext.Post(this.m_invokeHandlers, value);
            }
        }
        [__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        void IProgress<T>.Report(T value)
        {
            this.OnReport(value);
        }
        private void InvokeHandlers(object state)
        {
            T t = (T)((object)state);
            Action<T> handler = this.m_handler;
            EventHandler<T> progressChanged = this.ProgressChanged;
            if (handler != null)
            {
                handler(t);
            }
            if (progressChanged != null)
            {
                progressChanged(this, t);
            }
        }
    }
}

源代码取自ReSharper反编译器:

// Decompiled with JetBrains decompiler
// Type: System.Progress`1
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 85AB3664-E4CA-41A0-86E3-96342ED95AAA
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

using System.Threading;

namespace System
{
  /// <summary>Provides an <see cref="T:System.IProgress`1" /> that invokes callbacks for each reported progress value.</summary>
  /// <typeparam name="T">Specifies the type of the progress report value.</typeparam>
  [__DynamicallyInvokable]
  public class Progress<T> : IProgress<T>
  {
    private readonly SynchronizationContext m_synchronizationContext;
    private readonly Action<T> m_handler;
    private readonly SendOrPostCallback m_invokeHandlers;

    /// <summary>Raised for each reported progress value.</summary>
    [__DynamicallyInvokable]
    public event EventHandler<T> ProgressChanged;

    /// <summary>Initializes the <see cref="T:System.Progress`1" /> object.</summary>
    [__DynamicallyInvokable]
    public Progress()
    {
      this.m_synchronizationContext = SynchronizationContext.CurrentNoFlow ?? ProgressStatics.DefaultContext;
      this.m_invokeHandlers = new SendOrPostCallback(this.InvokeHandlers);
    }

    /// <summary>Initializes the <see cref="T:System.Progress`1" /> object with the specified callback.</summary>
    /// <param name="handler">A handler to invoke for each reported progress value. This handler will be invoked in addition to any delegates registered with the <see cref="E:System.Progress`1.ProgressChanged" /> event. Depending on the <see cref="T:System.Threading.SynchronizationContext" /> instance captured by the <see cref="T:System.Progress`1" /> at construction, it is possible that this handler instance could be invoked concurrently with itself.</param>
    [__DynamicallyInvokable]
    public Progress(Action<T> handler)
      : this()
    {
      if (handler == null)
        throw new ArgumentNullException("handler");
      this.m_handler = handler;
    }

    /// <summary>Reports a progress change.</summary>
    /// <param name="value">The value of the updated progress.</param>
    [__DynamicallyInvokable]
    protected virtual void OnReport(T value)
    {
      // ISSUE: reference to a compiler-generated field
      if (this.m_handler == null && this.ProgressChanged == null)
        return;
      this.m_synchronizationContext.Post(this.m_invokeHandlers, (object) value);
    }

    [__DynamicallyInvokable]
    void IProgress<T>.Report(T value)
    {
      this.OnReport(value);
    }

    private void InvokeHandlers(object state)
    {
      T e = (T) state;
      Action<T> handler = this.m_handler;
      // ISSUE: reference to a compiler-generated field
      EventHandler<T> progressChanged = this.ProgressChanged;
      if (handler != null)
        handler(e);
      if (progressChanged == null)
        return;
      progressChanged((object) this, e);
    }
  }
}

源代码取自ReSharper反编译器:

// Decompiled with JetBrains decompiler
// Type: System.Progress`1
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 85AB3664-E4CA-41A0-86E3-96342ED95AAA
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

using System.Threading;

namespace System
{
  /// <summary>Provides an <see cref="T:System.IProgress`1" /> that invokes callbacks for each reported progress value.</summary>
  /// <typeparam name="T">Specifies the type of the progress report value.</typeparam>
  [__DynamicallyInvokable]
  public class Progress<T> : IProgress<T>
  {
    private readonly SynchronizationContext m_synchronizationContext;
    private readonly Action<T> m_handler;
    private readonly SendOrPostCallback m_invokeHandlers;

    /// <summary>Raised for each reported progress value.</summary>
    [__DynamicallyInvokable]
    public event EventHandler<T> ProgressChanged;

    /// <summary>Initializes the <see cref="T:System.Progress`1" /> object.</summary>
    [__DynamicallyInvokable]
    public Progress()
    {
      this.m_synchronizationContext = SynchronizationContext.CurrentNoFlow ?? ProgressStatics.DefaultContext;
      this.m_invokeHandlers = new SendOrPostCallback(this.InvokeHandlers);
    }

    /// <summary>Initializes the <see cref="T:System.Progress`1" /> object with the specified callback.</summary>
    /// <param name="handler">A handler to invoke for each reported progress value. This handler will be invoked in addition to any delegates registered with the <see cref="E:System.Progress`1.ProgressChanged" /> event. Depending on the <see cref="T:System.Threading.SynchronizationContext" /> instance captured by the <see cref="T:System.Progress`1" /> at construction, it is possible that this handler instance could be invoked concurrently with itself.</param>
    [__DynamicallyInvokable]
    public Progress(Action<T> handler)
      : this()
    {
      if (handler == null)
        throw new ArgumentNullException("handler");
      this.m_handler = handler;
    }

    /// <summary>Reports a progress change.</summary>
    /// <param name="value">The value of the updated progress.</param>
    [__DynamicallyInvokable]
    protected virtual void OnReport(T value)
    {
      // ISSUE: reference to a compiler-generated field
      if (this.m_handler == null && this.ProgressChanged == null)
        return;
      this.m_synchronizationContext.Post(this.m_invokeHandlers, (object) value);
    }

    [__DynamicallyInvokable]
    void IProgress<T>.Report(T value)
    {
      this.OnReport(value);
    }

    private void InvokeHandlers(object state)
    {
      T e = (T) state;
      Action<T> handler = this.m_handler;
      // ISSUE: reference to a compiler-generated field
      EventHandler<T> progressChanged = this.ProgressChanged;
      if (handler != null)
        handler(e);
      if (progressChanged == null)
        return;
      progressChanged((object) this, e);
    }
  }
}

如果您对原始源代码感兴趣,Microsoft已使其在internet上可用。进度类的来源可在此处找到:


如果您对原始源代码感兴趣,Microsoft已使其在internet上可用。进度类的来源可在此处找到:


安装4.5,安装反射器或ilspy的演示,等等…我知道,但我不能安装它,我已经编辑了我的问题超级要求。。。英雄联盟你不可能滥用任何其他计算机来执行此操作?你可能正在搜索作业调度程序。在这种情况下,可能是可以帮助你。顺便说一句-你可以将你的visual studio链接到符号服务器并逐步实现..安装4.5,安装reflector或ilspy的演示等等…我知道,但我无法安装我编辑了我的问题超级要求。。。英雄联盟你不可能滥用任何其他计算机来执行此操作?你可能正在搜索作业调度程序。在这种情况下,您可以帮助您。顺便说一句-您可以将visual studio链接到符号服务器,并逐步完成实现..Ahhh确定。唯一的选择是使用另一台可以安装它的电脑。尽管.NET源代码可用,但您不能像浏览公共存储库一样简单地浏览它。您需要使用.NET Reflector或dotPeek之类的工具,甚至在配置为这样做时使用Visual Studio本身来下载.NET framework的符号。这将允许您查看源代码。我希望安装了.NET 4.5的人为我执行此操作,因为我没有.NET 4.5。我无法安装它,因为它会覆盖.NET 4。即使安装了.NET 4.5,您也可以将.NET 4.0作为目标,@bbaia.Ahhh OK。唯一的选择是使用另一台可以安装它的电脑。尽管.NET源代码可用,但您不能像浏览公共存储库一样简单地浏览它。您需要使用.NET Reflector或dotPeek之类的工具,甚至在配置为这样做时使用Visual Studio本身来下载.NET framework的符号。这将允许您查看源代码。我希望安装了.NET 4.5的人为我执行此操作,因为我没有.NET 4.5。我无法安装它,因为它会覆盖.NET 4。即使安装了.NET 4.5,@bbaia,您也可以将.NET 4.0作为目标。