Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7726343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:11:23+00:00 2026-06-01T05:11:23+00:00

We have an application that has a primary window, it can launch multiple other

  • 0

We have an application that has a primary window, it can launch multiple other windows, in new browsers. We are using a silverlight application as a coordinating server in the primary window to close all windows that are part of the app, regardless of the way they are opened (we can’t guarantee it was via window.open so don’t always have a handle to the window in javascript).

On log out, we want to signal all the other windows to perform an auto-save, if necessary, then close down.

So all windows have a silverlight app, they coordinate using localmessagesenders. However, these are asynchronous:

private void ProcessAutosave()
    {
        foreach (string s in _windows)
        {
            SendMessage(s, "notify-logout");
        }
        // code here quoted later...

    }

    // sendasynch doesn't send until the method terminates, so have to do it in it's own function.
    private void SendMessage(string to, string message)
    {
        var lms = new LocalMessageSender(to);
        lms.SendCompleted += new EventHandler<SendCompletedEventArgs>(SenderSendCompleted);
        lms.SendAsync(message);
    }

Since the ProcessAutosave is called from a javascript onunload event which can’t be cancelled, we need this to be synchronous and not complete before we have a response processed from each sub-window so the session state will still be valid etc.

In the SenderSendCompleted we remove items from _windows when they have said they’re done.

So I added a loop on the end:

while(_windows.Count > 0) {
 Thread.Sleep(1)
}

However, that never terminates, unless I put an iteration counter on it.

Am I the victim of a compiler optimisation meaning the changes in SenderSendCompleted do not affect that while loop, or, have I fundamentally misunderstood something? Or missed something obvious that’s staring me in the face?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:11:24+00:00Added an answer on June 1, 2026 at 5:11 am

    I have found a way to work round. However, this does not really “solve” the problem generally, just in my case, which is also only supporting internet explorer.

    function WindowCloseEventHandler()
    {
       var app = // get silverlight app handle...
       app.doAutoSave();
       var params = 'whatever you need';
       var args = new Object();
       args.hwnd = window;
       window.showModalDialog('blocker.aspx',args,params);
    }
    
    function checkAutoSave()
    {
       var app = // get silverlight app handle...
       return app.autosavecomplete();
    }
    

    Then in blocker.aspx we display a static “performing logout handlers” type message and do:

    function timerTick()
    {
        if(window.dialogArguments.hwnd.checkAutoSave()) {
          window.close();
        } else {
           setTimeout(timerTick, 500);
        }
    }
    

    And start the timer on window load.

    The child window’s silverlight apps are notified to start an autosave, then they notify the parent when they are done. We then poll the parent’s status from a modal dialog, which blocks the termination of the WindowCloseEventHandler() which we have wired up to the onclose event of the body.

    It’s hacky and horrible, but it means silverlight stays asynchronous and we’re using a javascript timer so the javascript isn’t loading the system.

    Of course if the user closes the modal dialogue, there is a potential for issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has a primary layout of portrait (it is fixed
We have an application that has one or more text console windows that all
I have an application that has multiple states, with each state responding to input
When building an application and you are using a table that has a primary
We have an application that has to be flexible in how it displays it's
I have an application that has created a number of custom event log sources
I have an application that has Powershell 1 embedded into it, but we need
I have an application that has many different types of objects that each persist
I have an application that has several objects (about 50 so far, but growing).
I have an application that has to deal with getting special characters in its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.