C# Error : Creating Window Handle (Not Solve)

Try solution

1. Guna Invoke((MethodInvoker)delegate v


this.Invoke((MethodInvoker)delegate { 
 //call your method here 
}); 

private void ultraButton1_Click(object sender, EventArgs e) { 
 Task.Factory.StartNew(() => myMethod1()); 

void myMethod1() { 
 //my logic 
 this.Invoke((MethodInvoker)delegate { 
   ultraDesktopAlert1.Show($"my message header", "my message"); 
 });



2. Sebab timer

Rujukan : High ram load and “Error creating window handle” exception


3. Before adding handlers for events , First remove them


RemoveHandler objReportViewer.LocalReport.SubreportProcessing, AddressOf SubReportProcessing

AddHandler objReportViewer.LocalReport.SubreportProcessing, AddressOf SubReportProcessing


Rujukan : Error creating window handle


4. Kena Dispose Graphic / Pen


OK, everyone is focused on the Pen. That's not the problem in the code you posted.

Well, there is one small problem where you're not disposing the Pen before your app terminates. This will lead to a handle leak and eventually break Window but you have to run this app over and over again, thousands of times, before that happens.

The problem is that you're looking at Task Manager to see how much memory your app is using. That's the WRONG place to look. It's showing you how much memory the .NET CLR has RESERVED for your application, not how much it's using.

If you want to see how much is actually is use, use PerfMon and the .NET memory counters or a CLR memory profiler to see what's actually being used.


Rujukan : C# Memory leak in GDI+


5. Kena guna using statement

Rujukan : using statement (C# Reference)


6. Clear event handler

Rujukan : What best practices for cleaning up event handler references?


7. Dispose Pen ?

Rujukan : C#: Is it necessary to dispose of a graphics element inside a custom control?

Graphics.Dispose Method

Do I need to call Graphics.Dispose()?




Ulasan

Catatan popular daripada blog ini

SISTEM PENGOPERASIAN KOMPUTER (OS)

JENIS-JENIS SISTEM PENGOPERASIAN KOMPUTER

APA ITU ASCII (AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE) ?