mike
mike

Reputation: 550

Silverlight 4 application freezes without throwing any exception

I'm developing a Silverlight 4 RIA application. There is a DataGrid storing data and two buttons: add a new item and remove an item. After creating a new item for the second time the application freezes like this - I'll explain the strange behaviour below.

The scenario of creating a new item looks like this:

  1. After clicking, the child window appears. The reference to the domain data source used on the parrent page is being passed to the child window in the constructor.
  2. The user chooses a file.
  3. The file is send to a web service. In response the web service returns some data from that file.
  4. A new data object is being created and inserted to domain data source.

The child window causes the entire application to freeze only when it's called twice, but the first call requires object creation. I can open and close the child window repeatedly and everything will work fine until a sequence of: open.create -> open.close / open.create occurs. I tried to trace all exceptions with VS tool (alt ctrl e) but there are none.

A breakpoint on

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)

does not show anything either. Any ideas?

Page code. Child window code

Upvotes: 2

Views: 1069

Answers (2)

mike
mike

Reputation: 550

I did a bit more research after you helped me with this issue. Seems its a SL4 bug. This should also help. Topic about this on SL forums.

protected override void OnClosed(EventArgs e)
    {
        base.OnClosed(e);
        Application.Current.RootVisual.SetValue(Control.IsEnabledProperty, true);
    }

Upvotes: 0

Nikos Tsokos
Nikos Tsokos

Reputation: 3356

Remove the following and everything will be fine.

    private void ChildWindow_Closed(object sender, EventArgs e)
    {
        this.DialogResult = false;
    }

And to evaluate a bit more, ChildWindow_Closed is the outcome of setting the DialogResult at the first place. By re setting it unexpected things happen.

Upvotes: 1

Related Questions