![](/img/trans.png)
[英]Moved some code to a new class why im getting cannot convert error on the AnimatedPictureBox[] pbs?
[英]Why im getting an error when creating an event in my new class?
我不理解erorr消息以及如何解决它以及它为什么会发生。 这是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Threading;
namespace GatherLinks
{
class BackgroundWebCrawling
{
public string f;
int counter = 0;
List<string> WebSitesToCrawl;
int MaxSimultaneousThreads;
BackgroundWorker mainBackGroundWorker;
BackgroundWorker secondryBackGroundWorker;
WebcrawlerConfiguration webcrawlerCFG;
List<WebCrawler> webcrawlers;
int maxlevels;
public event EventHandler<BackgroundWebCrawling> ProgressEvent;
错误发生在ProgressEvent上
错误1类型'GatherLinks.BackgroundWebCrawling'不能用作泛型类型或方法'System.EventHandler'中的类型参数'TEventArgs'。 没有从'GatherLinks.BackgroundWebCrawling'到'System.EventArgs'的隐式引用转换。
EventHandler<T>
签名(至少最初是)用于args
(在common sender
/ args
模式中)是EventArgs
某个子类的场景。 因此,有一个where T : EventArgs
约束(编辑 - 作为ByteBlast说明:直到.NET 4.5,其中约束被删除 )
BackgroundWebCrawling
不是 EventArgs
。 除此之外,没有必要将它作为args
发送,因为你可能已经发送它( this
)作为sender
。
如果您没有要发送的有趣args,只需使用非泛型EventHandler
,然后发送EventArgs.Empty
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.