c#代码,改写成vb.net代码

publicMainWindow(){InitializeComponent();_spider=newSpider();_spider.ContentsSaved+=n... public MainWindow()
{
InitializeComponent();
_spider = new Spider();
_spider.ContentsSaved += new Spider.ContentsSavedHandler(Spider_ContentsSaved);
_spider.DownloadFinish += new Spider.DownloadFinishHandler(Spider_DownloadFinish);
this.Closed += new EventHandler(MainWindow_Closed);
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
btnStop.IsEnabled = false;
}

void Spider_DownloadFinish(int count)
{
DFHandler h = c =>
{
_spider.Abort();
btnDownload.IsEnabled = true;
btnDownload.Content = "Download";
btnStop.IsEnabled = false;
MessageBox.Show("Finished " + c.ToString());
};
Dispatcher.Invoke(h, count);
}
展开
 我来答
菜一天
2013-06-28 · TA获得超过179个赞
知道小有建树答主
回答量:86
采纳率:0%
帮助的人:86.7万
展开全部
Public Sub New()
InitializeComponent()
_spider = New Spider()
_spider.ContentsSaved += New Spider.ContentsSavedHandler(Spider_ContentsSaved)
_spider.DownloadFinish += New Spider.DownloadFinishHandler(AddressOf Spider_DownloadFinish)
Me.Closed += New EventHandler(MainWindow_Closed)
Me.Loaded += New RoutedEventHandler(MainWindow_Loaded)
btnStop.IsEnabled = False
End Sub

Private Sub Spider_DownloadFinish(count As Integer)
Dim h As DFHandler = Function(c)
_spider.Abort()
btnDownload.IsEnabled = True
btnDownload.Content = "Download"
btnStop.IsEnabled = False
MessageBox.Show("Finished " & c.ToString())

End Function
Dispatcher.Invoke(h, count)
End Sub
追问
void Spider_ContentsSaved(string path, string url)
{ CSHandler h = (p, u) =>
{ListDownload.Items.Add(new { Url = u, File = p }); };
Dispatcher.Invoke(h, path, url); }
追答
Private Sub Spider_ContentsSaved(path As String, url As String)
Dim h As CSHandler = Function(p, u)
ListDownload.Items.Add(New With { _
Key .Url = u, _
Key .File = p _
})

End Function
Dispatcher.Invoke(h, path, url)
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式