I would suggest adding textbox1 value change event to change global variable and then use this variable in the new thread without crash
That would work, what if I edit the textbox with the thread running ? GUI tries to access the variable while the new thread also does. Textbox1.enabled = false while spamming is a solution.
- - - Updated - - -
Originally Posted by Zaczero
I have never had any problems with aborting the thread or pausing it to resume it later
If you have some long running code that you want to take down cleanly, aborting is definetely not a solution. It's an emergency solution. In such a small function, there should be no problems however.
Originally Posted by PKTINOS
That would work, what if I edit the textbox with the thread running ? GUI tries to access the variable while the new thread also does. Textbox1.enabled = false while spamming is a solution.
Don't worry
It won't crash
It is more smarter than you can think
I have been using control change => variable => other thread a lot in my cheats
Originally Posted by Zaczero
Don't worry
It won't crash
It is more smarter than you can think
I never said it would crash. Two threads accessing the same value can cause a race condition, that would cause OP's program to not work as expected.
Originally Posted by PKTINOS
I never said it would crash. Two threads accessing the same value can cause a race condition, that would cause OP's program to not work as expected.
I have never had any problems like that before
Originally Posted by Zaczero
I have never had any problems like that before
You probably won't ever have, but "the problem doesn't occur in your program" doesn't equal "this problem does not exist".
Can you help me out and explain it more? I'm currently learning and I don't get what you mean. I want it to run with hotkeys, what is that Global thing?
Can you help me out and explain it more? I'm currently learning and I don't get what you mean. I want it to run with hotkeys, what is that Global thing?
Can you help me out and explain it more? I'm currently learning and I don't get what you mean. I want it to run with hotkeys, what is that Global thing?
A global hotkey, is a hotkey that doesn't require focus of the window in order to capture.
Use winapi's (Un)Registerhotkey methods
Code:
[DllImport("user32.dll")]private static extern int RegisterHotKey(IntPtr hwnd, int id,int fsModifiers, int vk);
[DllImport("user32.dll")] private static extern int UnregisterHotKey(IntPtr hwnd, int id);