Javascript and .NET circular dependency

88 views Asked by At

A .NET application I've been working on is hanging on a certain function call, and I think it is because there are a certain 4 function creating circular dependency. I've included an outline of the functions and other functions that they call:

Javascript

// Fires on user scroll event
function ScrollHandler() {
    //...
    // Calls the following C# function when a user scrolls
    window.external.UserScroll();
}

// Called by C# function UpLoadJson()
function drawTimeline(JsonData) { 
    //...
}

C#

// Called by Javascript function ScrollHandler()
void UserScroll()
{
    //...
    UpLoadJson();
}

void UpLoadJson()
{
    //...
    browser.Document.InvokeScript("drawTimeline", new String[] {data});
}

Using "->" to denote a function call, what I think is happening is:

ScrollHandler(/*JS*/) -> UserScroll(/*C#*/) -> UpLoadJson(/*C#*/) -> drawTimeline(/*JS*/)

But the Javascript can't run drawTimeline() because it is waiting for ScrollHandler() to return first; this can't return until drawTimeline() is called though.

Is this possibly why my application hangs on this function call? What can I do to fix this?

0

There are 0 answers