2016-08-13 4 views
0

誰でも助けてくれますか? 私が持っている2種類のエラーメッセージラムダ式を変換できません&名前 '_'は現在のコンテキストに存在しません

  1. 「closure_」は現在のコンテキスト内に存在しない名前それは ので「System.Delegate」と入力するラムダ式を変換できません

  2. ないデリゲート型

コードは次のとおりです。

private void backgroundWorker3_DoWork(object sender, DoWorkEventArgs e) 
{ 
    HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument(); 
    string text = this.textBox5.Text; 
    htmlDocument.LoadHtml(text); 
    HtmlNodeCollection htmlNodeCollection = htmlDocument.DocumentNode.SelectNodes("//img/@alt"); 
    int num1 = 0; 
    int k = 0; 
    if (htmlNodeCollection == null || this.backgroundWorker3.CancellationPending) 
    return; 
    string links = ""; 
    foreach (HtmlNode htmlNode in (IEnumerable<HtmlNode>) htmlNodeCollection) 
    { 
    HtmlNode aTag = htmlNode; 
    int num2 = int.Parse(this.textBox7.Text); 
    this._busy.WaitOne(-1); 
    if (!this.backgroundWorker3.CancellationPending) 
    { 
     ++k; 
     this.Invoke((Delegate) (() => this.richTextBox4.AppendText(k.ToString() + "." + Environment.NewLine + aTag.InnerHtml + aTag.Attributes["alt"].Value + Environment.NewLine + Environment.NewLine))); 
     ++num1; 
    } 
    this.Invoke((Delegate) (closure_0 ?? (closure_0 = (Action) (() => links = this.richTextBox4.Text + Environment.NewLine)))); 
    System.IO.File.WriteAllText(this.textBox2.Text + "/Descriptions.txt", links); 
    if (num1 == num2) 
    { 
     this.backgroundWorker3.CancelAsync(); 
     if (!this.backgroundWorker3.CancellationPending) 
     this._busy.Reset(); 
    } 
    } 
} 

Here is screenshoot

ありがとう

答えて

0

このライン役に立たないコードです:

this.Invoke((Delegate) (closure_0 ?? (closure_0 = (Action) (() => links = this.richTextBox4.Text + Environment.NewLine)))); 

あなたが安全に置き換えることができます。

this.Invoke(new Action(() => { links = this.richTextBox4.Text + Environment.NewLine; })); 

あなたが最初の問題があるということです01という変数またはクラスフィールドはありませんあなたが示したコードまで。

第2に、UIでアクションを呼び出すための構文が複雑で間違っているため、上記の単純なアプローチを使用します。

+0

私は非常に古いソースコードを失ってしまったので、私は初心者です。私のプログラムはjetbrain dotpeekで逆コンパイルしています。私は本当にいくつかの不足しているコードを理解していない。そして今、あなたは私の問題を解決します、もう一度、ありがとう、 – userrrrrrr

関連する問題