Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Debugging hangs if an event handler for a UI element is set and event handler gets executed (V8)

$
0
0
Hi,

I am using a modified version of node-inspector which is a V8-compatible debugger.

I think this is a thread related issue because I made another test using delegates.

Here is the related C# code:
        public delegate void FormEvent(string eventName, object sender, EventArgs e);
        private FormEvent callbacks;

        public void RegisterToFormEvents(FormEvent eventHandler)
        {
            callbacks += eventHandler;
        }

        private void MainForm_Resize(object sender, EventArgs e)
        {
                new Thread(() =>
                {
                    if (callbacks != null)
                        callbacks("Resize", sender, e);
                }).Start();           
        }

And here is the Javascript code:
var callback1 = host.del(FormEvent, function (eventName, sender, e) {
    Console.WriteLine(eventName + " triggered");
});
main.RegisterToFormEvents(callback1);
I run the script and put a breakpoint at "Console.WriteLine" line.

The following calling method makes the Winforms application hang when it hits the breakpoint:
                    if (callbacks != null)
                        callbacks("Resize", sender, e);
If I call it in a new thread, it works fine:
                new Thread(() =>
                {
                    if (callbacks != null)
                        callbacks("Resize", sender, e);
                }).Start();           

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>