0

I have one problem when winform opening long time if I sent another request is giving Error creating window handle for flowlayout panel control clearing:

 flw.Invoke(new Action(() => flw.Controls.Clear()));

Error : ERROR OnExampleDTOReceived:Error creating window handle.-->-->System.ComponentModel.Win32Exception: Error creating window handle. 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 PrxCustScr.Sockets.Listener.EndTrx(String data, FlowLayoutPanel flw) in \Source\Workspaces\TestApplications\PrxCustScr\PrxCustScr\Sockets\Listener.cs:line 689 at PrxCustScr.Sockets.Listener.OnExampleDTOReceived(String message) in \Source\Workspaces\TestApplications\PrxCustScr\PrxCustScr\Sockets\Listener.cs:line 273--> 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 PrxCustScr.Sockets.Listener.EndTrx(String data, FlowLayoutPanel flw) in \Source\Workspaces\TestApplications\PrxCustScr\PrxCustScr\Sockets\Listener.cs:line 689 at PrxCustScr.Sockets.Listener.OnExampleDTOReceived(String message) in \Source\Workspaces\TestApplications\PrxCustScr\PrxCustScr\Sockets\Listener.cs:line 273

How can I solve this problem ?

Sezer Erdogan
  • 167
  • 1
  • 9
  • 34
  • Check status of connect at client and server from cmd.exe >Netstat -a which will give a list of port numbers and status of the connection. The connection may be closing so check when working and not working. – jdweng Jul 13 '20 at 08:32

1 Answers1

1

I solved with this code :

http://www.codeease.com/windows-form-flowlayoutpanel-memory-leak.html

for(int i = flowlayoutpanel1.Controls.Count-1; i >= 0; --i)
{ 
   var ctl = flowlayoutpanel1.Controls[i];
    ctl.Dispose();
}
Sezer Erdogan
  • 167
  • 1
  • 9
  • 34