[Roam-commit] SF.net SVN: roam: [124] Trunk/Source/Roam.UI/Forms/RoamForm.cs
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2008-03-11 19:17:11
|
Revision: 124
http://roam.svn.sourceforge.net/roam/?rev=124&view=rev
Author: jonfroehlich
Date: 2008-03-11 12:17:09 -0700 (Tue, 11 Mar 2008)
Log Message:
-----------
updated RoamForm to be threadsafe (hopefully)
Modified Paths:
--------------
Trunk/Source/Roam.UI/Forms/RoamForm.cs
Modified: Trunk/Source/Roam.UI/Forms/RoamForm.cs
===================================================================
--- Trunk/Source/Roam.UI/Forms/RoamForm.cs 2008-03-11 06:59:31 UTC (rev 123)
+++ Trunk/Source/Roam.UI/Forms/RoamForm.cs 2008-03-11 19:17:09 UTC (rev 124)
@@ -31,30 +31,73 @@
/// <author>Jon Froehlich</author>
public partial class RoamForm : Form
{
+ #region Fields
private bool _isModal = false;
private bool _isClosed = false;
private bool _isDisposed = false;
+ private object _objLock = new object();
+ #endregion Fields
+ #region Constructors
public RoamForm()
{
InitializeComponent();
}
+ #endregion Constructors
#region Properties
public bool IsClosed
{
- get { return _isClosed; }
- protected set { _isClosed = value; }
+ get
+ {
+ lock (_objLock)
+ {
+ return _isClosed;
+ }
+ }
+ protected set
+ {
+ lock (_objLock)
+ {
+ _isClosed = value;
+ }
+ }
}
public bool IsDisposed
{
- get { return _isDisposed; }
+ get
+ {
+ lock (_objLock)
+ {
+ return _isDisposed;
+ }
+ }
+ private set
+ {
+ lock (_objLock)
+ {
+ _isDisposed = value;
+ }
+ }
}
public bool IsModal
{
- get { return _isModal; }
+ get
+ {
+ lock (_objLock)
+ {
+ return _isModal;
+ }
+ }
+ private set
+ {
+ lock (_objLock)
+ {
+ _isModal = value;
+ }
+ }
}
public new DialogResult DialogResult
@@ -62,22 +105,25 @@
get { return base.DialogResult; }
set
{
- base.DialogResult = value;
+ lock (_objLock)
+ {
+ base.DialogResult = value;
- //The following is a workaround relating to the differences between form.ShowDialog()
- //and Application2.ShowDialog()
- //
- //Setting the DialogResult property with a value from the DialogResult enumeration
- //sets the value of the dialog box result for the form, hides the modal
- //dialog box, and returns control to the calling form. However, this does
- //NOT work properly if the form was started using Application2.ShowDialog.
- //In this case, setting the dialog result does not infact hide the modal dialog
- //box. So we will do that ourselves here.
- //
- //In addition, if a form was shown via form.Show(), setting its DialogResult
- //has no effect. This changes that behavior such that it is consistent with
- //form.ShowDialog()
- if (!_isClosed) { this.Close(); }
+ //The following is a workaround relating to the differences between form.ShowDialog()
+ //and Application2.ShowDialog()
+ //
+ //Setting the DialogResult property with a value from the DialogResult enumeration
+ //sets the value of the dialog box result for the form, hides the modal
+ //dialog box, and returns control to the calling form. However, this does
+ //NOT work properly if the form was started using Application2.ShowDialog.
+ //In this case, setting the dialog result does not infact hide the modal dialog
+ //box. So we will do that ourselves here.
+ //
+ //In addition, if a form was shown via form.Show(), setting its DialogResult
+ //has no effect. This changes that behavior such that it is consistent with
+ //form.ShowDialog()
+ if (!IsClosed) { this.Close(); }
+ }
}
}
#endregion Properties
@@ -85,15 +131,15 @@
#region Public Methods
public new DialogResult ShowDialog()
{
- _isModal = true;
+ IsModal = true;
DialogResult dr = base.ShowDialog();
- _isModal = false;
+ IsModal = false;
return dr;
}
public new void Show()
{
- _isModal = false;
+ IsModal = false;
base.Show();
}
#endregion Public Methods
@@ -101,7 +147,7 @@
#region Protected Methods
protected override void OnClosed(EventArgs e)
{
- _isClosed = true;
+ IsClosed = true;
base.OnClosed(e);
}
#endregion Protected Methods
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|