public void SetSource(MemberInfo memberInfo, IEnumerable<HighlightItem> highlightItems, CancellationToken cancelToken) { if (memberInfo == null) { return; } this.MemberInfo = memberInfo; this.lastHighlightItems = (highlightItems ?? new HighlightItem[0]).ToList(); if (!this.Enabled) { return; } try { this.OnProgressChanged(false); lock (this) { if (this.MemberInfo != memberInfo) { // it changed while waiting in the lock return; } this.InvokeIfRequired(() => { this.Reset(); if (this.MethodChanged != null) { this.MethodChanged(this, new EventArgs()); } }); this.TextBox = this.CreateTextBox(); this.Reset(); Highlighter highlighter = new Highlighter(this, highlightItems); DecompilerSettings settings = new DecompilerSettings() { UsingDeclarations = this.ShowUsing, ShowXmlDocumentation = this.ShowXmlDoc, UseDebugSymbols = true }; settings.AnonymousMethods = settings.ExpressionTrees = settings.YieldReturn = settings.AutomaticProperties = settings.AutomaticEvents = settings.UsingStatement = settings.ForEachStatement = settings.LockStatement = settings.SwitchStatementOnString = settings.QueryExpressions = settings.ObjectOrCollectionInitializers = this.DecompileLanguageFeatures; // vb.net stuff: settings.IntroduceIncrementAndDecrement = settings.AlwaysGenerateExceptionVariableForCatchBlocks = this.DecompileLanguageFeatures; if (memberInfo is PropertyInfo) { ((PropertyInfo)memberInfo).DecompileProperty(highlighter, settings); } else { ((MethodBase)memberInfo).DecompileMethod(highlighter, settings); } highlighter.Complete(); int pos = this.TextBox.SelectionStart; string rtf = this.TextBox.Rtf; this.TextBox = this.DisplayedTextBox; this.InvokeIfRequired(() => { if (first) { this.DisplayedTextBox.ScrollBars = RichTextBoxScrollBars.ForcedBoth; this.DisplayedTextBox.ScrollBars = RichTextBoxScrollBars.Both; this.first = false; } this.Reset(); this.DisplayedTextBox.Rtf = rtf; this.DisplayedTextBox.Select(pos, 0); this.DisplayedTextBox.ScrollToCaret(); }); } } finally { this.OnProgressChanged(true); } }