C#到vbnet代表 [英] c# to vbnet delegates

查看:88
本文介绍了C#到vbnet代表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我一直在尝试使用此网站翻译部分代码:
http://www.developerfusion.com/tools/convert/csharp-to-vb/ [^ ]
http://converter.telerik.com/ [ ^ ]
但是我不能让它在这部分上特别起作用:

Hi Ive been trying to translate part of a code using this websites :
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
http://converter.telerik.com/[^]
But I could not make it work specially this part :

bw.DoWork += delegate(object sender2, DoWorkEventArgs e2)
                   {
                       _lastImageUploadDetails = uploader.UploadImage(txtFilePath.Text, resizeWidth, resizeHeight);
                   };



这是我希望您帮助我的信息源:




This is the source I would like you to help me out :


bw.DoWork += delegate(object sender2, DoWorkEventArgs e2)
     {
         _lastImageUploadDetails = uploader.UploadImage(txtFilePath.Text, resizeWidth, resizeHeight);
     };

     bw.RunWorkerAsync();

     // when the background worker is finished, run this anonymous method which either updates
     // the details of the last uploaded image or displays an appropriate error message
     // if there were problems.
     bw.RunWorkerCompleted += delegate(object sender3, RunWorkerCompletedEventArgs e3)
     {
         try
         {
             if (e3.Error != null)
             {
                 throw e3.Error;
             }
             UpdateLastUploadedImageDisplayDetails(_lastImageUploadDetails); txtInfo.Text = "Image Uploaded.";
         }
         catch (FileNotFoundException exp)
         {
             txtInfo.Text = exp.Message;
         }
         catch (XmlException exp)
         {
             txtInfo.Text = exp.Message;
         }
     };




所以,如果有人可以的话,请知道这里的c#和vbnet,我将非常感激.
问候.




So please if anybody here knows some c# and vbnet if he could do it I will really appreciate it.
Regards.

推荐答案

为什么不使用标准的事件处理程序构造?

Why aren''t you using the standard event handler construct?

backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);



屈服:



Yielding:

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
    // Get the BackgroundWorker that raised this event.
    BackgroundWorker worker = sender as BackgroundWorker;

    // Assign the result of the computation
    // to the Result property of the DoWorkEventArgs
    // object. This is will be available to the
    // RunWorkerCompleted eventhandler.

    // e.Result = result of some action;
}



到那时,翻译器应该可以正常工作了……



At that point, the translator should work just fine...


这篇关于C#到vbnet代表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆