Label Cloud

Friday, December 21, 2007

Closing and Terminating views in SCSF

There is a bug in the SCSF implementation that views even though closed, will not terminate the workitems. This was described on codeplex in the following thread: http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=4370

Here is my workaround:

In the View.Designer.cs

protected override void Dispose(bool disposing)
{
if (disposing)
{
if (_presenter != null)
{
_presenter.OnCloseView(); // <<<<<<<<======= Workaround
_presenter.Dispose();
}

if (components != null)
components.Dispose();
}

base.Dispose(disposing);
}

In the ViewPresenter.cs

bool Closing = false;
public void OnCloseView()
{
if (!Closing)
{
Closing = true;
if (WorkItem.Status != WorkItemStatus.Terminated)
WorkItem.Terminate();

base.CloseView();
}
}

The code will force the workitem to be terminated after the view is closed

Technorati Tags: , ,


Share/Save/Bookmark

No comments: