private void manager_OnWebSiteVisited(object source, WebSiteVisitedEventArgs args)
{
if (InvokeRequired)
txtStatus.BeginInvoke(new WebSiteVisitedCallback(WebSiteVisited), new object[] { args });
else
txtStatus.Invoke(new WebSiteVisitedCallback(WebSiteVisited), new object[] { args });
}
InvokeEvent: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
i can use if (IsHandleCreated) but i do not know what to do if is not created. How to create it?
Just access the
Handleproperty, it will create the handle if it’s not already created. You can also call theCreateHandlemethod explicitly.By the way, your usage of
InvokeRequired/Invoke/BeginInvokeis wrong: ifInvokeRequiredis false, you shouldn’t useInvokeat all, you should call the method directly. I think what you want to do is this: