diff --git a/mRemoteV1/App/Import.cs b/mRemoteV1/App/Import.cs
index 41b259e59..1a7bdbf81 100644
--- a/mRemoteV1/App/Import.cs
+++ b/mRemoteV1/App/Import.cs
@@ -79,7 +79,7 @@ namespace mRemoteNG.App
}
}
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
}
catch (Exception ex)
@@ -93,7 +93,7 @@ namespace mRemoteNG.App
try
{
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOU);
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
catch (Exception ex)
{
@@ -107,7 +107,7 @@ namespace mRemoteNG.App
{
var importer = new PortScanImporter(protocol);
importer.Import(hosts, importDestinationContainer);
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
catch (Exception ex)
{
diff --git a/mRemoteV1/App/Runtime.cs b/mRemoteV1/App/Runtime.cs
index 5bc586a84..aae2811a9 100644
--- a/mRemoteV1/App/Runtime.cs
+++ b/mRemoteV1/App/Runtime.cs
@@ -192,21 +192,6 @@ namespace mRemoteNG.App
}
}
}
-
- public static void SaveConnectionsAsync()
- {
- var t = new Thread(SaveConnectionsBGd);
- t.SetApartmentState(ApartmentState.STA);
- t.Start();
- }
-
- private static readonly object SaveLock = new object();
- private static void SaveConnectionsBGd()
- {
- Monitor.Enter(SaveLock);
- ConnectionsService.SaveConnections();
- Monitor.Exit(SaveLock);
- }
#endregion
}
}
\ No newline at end of file
diff --git a/mRemoteV1/Connection/ConnectionsService.cs b/mRemoteV1/Connection/ConnectionsService.cs
index 1f4f27c28..eca7a6e3e 100644
--- a/mRemoteV1/Connection/ConnectionsService.cs
+++ b/mRemoteV1/Connection/ConnectionsService.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Threading;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.App.Info;
@@ -16,6 +17,7 @@ namespace mRemoteNG.Connection
{
public class ConnectionsService
{
+ private static readonly object SaveLock = new object();
private readonly PuttySessionsManager _puttySessionsManager;
public bool IsConnectionsFileLoaded { get; set; }
@@ -170,6 +172,20 @@ namespace mRemoteNG.Connection
}
}
+ public void SaveConnectionsAsync()
+ {
+ var t = new Thread(SaveConnectionsBGd);
+ t.SetApartmentState(ApartmentState.STA);
+ t.Start();
+ }
+
+ private void SaveConnectionsBGd()
+ {
+ Monitor.Enter(SaveLock);
+ SaveConnections();
+ Monitor.Exit(SaveLock);
+ }
+
public string GetStartupConnectionFileName()
{
return Settings.Default.LoadConsFromCustomLocation == false ? GetDefaultStartupConnectionFileName() : Settings.Default.CustomConsPath;
diff --git a/mRemoteV1/Tree/ConnectionTreeDragAndDropHandler.cs b/mRemoteV1/Tree/ConnectionTreeDragAndDropHandler.cs
index 9d5c4ae35..95e2a4073 100644
--- a/mRemoteV1/Tree/ConnectionTreeDragAndDropHandler.cs
+++ b/mRemoteV1/Tree/ConnectionTreeDragAndDropHandler.cs
@@ -26,7 +26,6 @@ namespace mRemoteNG.Tree
var dropSource = (ConnectionInfo)e.SourceModels[0];
DropModel(dropSource, dropTarget, e.DropTargetLocation);
e.Handled = true;
- Runtime.SaveConnectionsAsync();
}
public void DropModel(ConnectionInfo dropSource, ConnectionInfo dropTarget, DropTargetLocation dropTargetLocation)
diff --git a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs
index b43a591e8..cc405de95 100644
--- a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs
+++ b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs
@@ -748,13 +748,11 @@ namespace mRemoteNG.UI.Controls
private void OnAddConnectionClicked(object sender, EventArgs e)
{
_connectionTree.AddConnection();
- Runtime.SaveConnectionsAsync();
}
private void OnAddFolderClicked(object sender, EventArgs e)
{
_connectionTree.AddFolder();
- Runtime.SaveConnectionsAsync();
}
private void OnSortAscendingClicked(object sender, EventArgs e)
@@ -770,13 +768,11 @@ namespace mRemoteNG.UI.Controls
private void OnMoveUpClicked(object sender, EventArgs e)
{
_connectionTree.SelectedNode.Parent.PromoteChild(_connectionTree.SelectedNode);
- Runtime.SaveConnectionsAsync();
}
private void OnMoveDownClicked(object sender, EventArgs e)
{
_connectionTree.SelectedNode.Parent.DemoteChild(_connectionTree.SelectedNode);
- Runtime.SaveConnectionsAsync();
}
private void OnExternalToolClicked(object sender, EventArgs e)
diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs
index 103165ed9..1644165cb 100644
--- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs
+++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs
@@ -280,7 +280,6 @@ namespace mRemoteNG.UI.Controls
var newNode = SelectedNode.Clone();
SelectedNode.Parent.AddChildBelow(newNode, SelectedNode);
newNode.Parent.SetChildBelow(newNode, SelectedNode);
- Runtime.SaveConnectionsAsync();
}
public void RenameSelectedNode()
@@ -294,7 +293,6 @@ namespace mRemoteNG.UI.Controls
if (SelectedNode is RootNodeInfo || SelectedNode is PuttySessionInfo) return;
if (!NodeDeletionConfirmer.Confirm(SelectedNode)) return;
ConnectionTreeModel.DeleteNode(SelectedNode);
- Runtime.SaveConnectionsAsync();
}
public void SortRecursive(ConnectionInfo sortTarget, ListSortDirection sortDirection)
@@ -307,8 +305,6 @@ namespace mRemoteNG.UI.Controls
sortTargetAsContainer.SortRecursive(sortDirection);
else
SelectedNode.Parent.SortRecursive(sortDirection);
-
- Runtime.SaveConnectionsAsync();
}
private void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
@@ -389,7 +385,6 @@ namespace mRemoteNG.UI.Controls
_nodeInEditMode = false;
_allowEdit = false;
Windows.ConfigForm.SelectedTreeNode = SelectedNode;
- Runtime.SaveConnectionsAsync();
}
catch (Exception ex)
{
diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs
index 545117a15..840ad3a06 100644
--- a/mRemoteV1/UI/Forms/frmMain.cs
+++ b/mRemoteV1/UI/Forms/frmMain.cs
@@ -315,7 +315,7 @@ namespace mRemoteNG.UI.Forms
private void tmrAutoSave_Tick(object sender, EventArgs e)
{
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg, "Doing AutoSave");
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
#endregion
diff --git a/mRemoteV1/UI/Menu/MainFileMenu.cs b/mRemoteV1/UI/Menu/MainFileMenu.cs
index 422861f39..9a95be158 100644
--- a/mRemoteV1/UI/Menu/MainFileMenu.cs
+++ b/mRemoteV1/UI/Menu/MainFileMenu.cs
@@ -331,13 +331,11 @@ namespace mRemoteNG.UI.Menu
private void mMenFileNewConnection_Click(object sender, EventArgs e)
{
TreeWindow.ConnectionTree.AddConnection();
- Runtime.SaveConnectionsAsync();
}
private void mMenFileNewFolder_Click(object sender, EventArgs e)
{
TreeWindow.ConnectionTree.AddFolder();
- Runtime.SaveConnectionsAsync();
}
private void mMenFileNew_Click(object sender, EventArgs e)
@@ -372,7 +370,7 @@ namespace mRemoteNG.UI.Menu
private void mMenFileSave_Click(object sender, EventArgs e)
{
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
private void mMenFileSaveAs_Click(object sender, EventArgs e)
@@ -405,19 +403,16 @@ namespace mRemoteNG.UI.Menu
private void mMenFileDelete_Click(object sender, EventArgs e)
{
TreeWindow.ConnectionTree.DeleteSelectedNode();
- Runtime.SaveConnectionsAsync();
}
private void mMenFileRename_Click(object sender, EventArgs e)
{
TreeWindow.ConnectionTree.RenameSelectedNode();
- Runtime.SaveConnectionsAsync();
}
private void mMenFileDuplicate_Click(object sender, EventArgs e)
{
TreeWindow.ConnectionTree.DuplicateSelectedNode();
- Runtime.SaveConnectionsAsync();
}
private void mMenReconnectAll_Click(object sender, EventArgs e)
diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs
index f7a56fea5..ce1db9a9b 100644
--- a/mRemoteV1/UI/Window/ConfigWindow.cs
+++ b/mRemoteV1/UI/Window/ConfigWindow.cs
@@ -701,7 +701,7 @@ namespace mRemoteNG.UI.Window
UpdateRootInfoNode(e);
UpdateInheritanceNode();
ShowHideGridItems();
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
catch (Exception ex)
{
@@ -1592,7 +1592,7 @@ namespace mRemoteNG.UI.Window
connectionInfo.Icon = iconName;
_pGrid.Refresh();
- Runtime.SaveConnectionsAsync();
+ Runtime.ConnectionsService.SaveConnectionsAsync();
}
catch (Exception ex)
{
diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs
index 3f455e56d..d21667779 100644
--- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs
+++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs
@@ -160,13 +160,11 @@ namespace mRemoteNG.UI.Window
private void cMenTreeAddConnection_Click(object sender, EventArgs e)
{
olvConnections.AddConnection();
- Runtime.SaveConnectionsAsync();
}
private void cMenTreeAddFolder_Click(object sender, EventArgs e)
{
olvConnections.AddFolder();
- Runtime.SaveConnectionsAsync();
}
private void tvConnections_BeforeLabelEdit(object sender, LabelEditEventArgs e)
@@ -180,7 +178,6 @@ namespace mRemoteNG.UI.Window
{
_contextMenu.EnableShortcutKeys();
ConnectionTree.ConnectionTreeModel.RenameNode(SelectedNode, e.Label);
- Runtime.SaveConnectionsAsync();
}
catch (Exception ex)
{
diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj
index f040081e4..6c8120433 100644
--- a/mRemoteV1/mRemoteV1.csproj
+++ b/mRemoteV1/mRemoteV1.csproj
@@ -136,6 +136,7 @@
+