Feb 14, 2022 03:27 PM
(This post was last modified: Feb 14, 2022 03:45 PM by scriptsandapps.)
Hello, i want to create new forms and be able to use it like when the visual studio adds the forms, but programmatically..
Now trying this. I get the idea normally the forms all run in the same thread??.
How can i make it all in 1 thread instead of my method but still add and delete them.. without freezing form1
>>> Github ptoject Link <<<
>>>Download main.zip <<<
https://github.com/ScriptsAndApps/NotWor...n/Form1.cs
https://github.com/ScriptsAndApps/NotWor...AREFORM.cs
https://github.com/ScriptsAndApps/NotWor...UNDFORM.cs
Thanks
Now trying this. I get the idea normally the forms all run in the same thread??.
How can i make it all in 1 thread instead of my method but still add and delete them.. without freezing form1
>>> Github ptoject Link <<<
>>>Download main.zip <<<
https://github.com/ScriptsAndApps/NotWor...n/Form1.cs
Code
List<Thread> jt = new List<Thread>();
.................
Thread newThread = new Thread(() =>
{
Application.EnableVisualStyles();
Application.Run(jf[tl]); /////// this keeps thread running and form
jt[tl] = null; //clear thread after close
jf[tl] = null; //clear item in list after close
});https://github.com/ScriptsAndApps/NotWor...AREFORM.cs
Code
public SQUAREFORM()
{
InitializeComponent();
new Thread(() =>
{
while (!passthis.CloseApp)
{
if (!last && passthis.clickDisable)
{
last = true;
/*out of this thread error*/
uint initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
return;
}
else if (last && !passthis.clickDisable)
{
last = false;
System.Windows.Forms.MessageBox.Show("Test");
}
}
Thread.Sleep(100);
}).Start();
}https://github.com/ScriptsAndApps/NotWor...UNDFORM.cs
Code
private void timer1_Tick(object sender, EventArgs e)
{
if (!last && passthis.clickDisable)
{
last = true;
/*out of this thread error*/
this.Close()
/*out of this thread error*/
uint initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
}
else if (last && !passthis.clickDisable)
{
last = false;
}
}Thanks



![[Image: vp6iypF.gif]](https://i.imgur.com/vp6iypF.gif)