I get the following exception thrown:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
I am using betterlistviewer and dotnetbar just modifying this code Registry cleaner but i am trying to invoke that all classes and controls in another form not in the main.
This is my code
public Registry_Scan()
{
InitializeComponent();
StartScanning GeekStartCleaning = StartScanning.GeekCreateControl();
GeekStartCleaning.GeekOnAllScanComplete += GeekOnScanComplete;
this.GeekPanel.Controls.Add(GeekStartCleaning);
}
ScanComplete GeekOnComplete = new ScanComplete();
public void GeekOnScanComplete(ref List<BetterListViewGroup> _GeekListOfGroupTargets)
{
List<BetterListViewGroup> GeekListOfGroupTargets = _GeekListOfGroupTargets;
GeekOnComplete.GeekAddRangeTargets(ref GeekListOfGroupTargets);
GeekOnComplete.Show();
this.GeekPanel.Invoke(new MethodInvoker(() =>
{
this.GeekPanel.Controls.Clear();
this.GeekPanel.Controls.Add(GeekOnComplete);
}));
}
I don't know whats wrong please help
System.InvalidOperationException HResult=0x80131509 Message=Invoke or BeginInvoke cannot be called on a control until the window handle has been created. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) at System.Windows.Forms.Control.Invoke(Delegate method) at GeekCleaner.Registry_Scan.GeekOnScanComplete(List`1& _GeekListOfGroupTargets) in C:\Users\RamRo\source\repos\GeekVersion1\GeekCleaner\GeekCleaner\RegistryScan.cs:line 34 at GeekCleaner.UserPanel.StartScanning.GeekStartScanning() in C:\Users\RamRo\source\repos\GeekVersion1\GeekCleaner\GeekCleaner\UserPanel\StartScanning.cs:line 139 at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()