R
R
roman222752018-06-11 20:41:15
C++ / C#
roman22275, 2018-06-11 20:41:15

How to use multiple Application.run in c# program?

Classic form launch from the main function

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

        }

And here I run a hook to track mouse movement. Because of this, it gives an error
public static void start()
        {
            _hookID = SetHook(_proc);
           Application.Run();
            UnhookWindowsHookEx(_hookID);
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2018-06-11
@kttotto

No way. You can't run it twice in one thread. All UI forms run on the same thread.
Why don't you want to track mouse movement with standard windowsforms messages?
If you really want to run SetHook, then run it before Application.Run in main, and do tracking control inside this hook by the value of the boolean flag, which you will already change in start ().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question