[Roam-commit] SF.net SVN: roam: [117] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2008-02-21 19:46:20
|
Revision: 117
http://roam.svn.sourceforge.net/roam/?rev=117&view=rev
Author: jonfroehlich
Date: 2008-02-21 11:46:11 -0800 (Thu, 21 Feb 2008)
Log Message:
-----------
added HasActiveConnection method
Modified Paths:
--------------
Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs
===================================================================
--- Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs 2008-02-19 22:55:01 UTC (rev 116)
+++ Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs 2008-02-21 19:46:11 UTC (rev 117)
@@ -142,6 +142,24 @@
}
/// <summary>
+ /// Returns true if the current thread has an active connection
+ /// </summary>
+ /// <returns></returns>
+ public static bool HasActiveConnection()
+ {
+ return _connectionPool.HasActiveConnection(Thread.CurrentThread);
+ }
+
+ /// <summary>
+ /// Returns true if the provided thread has an active connection
+ /// </summary>
+ /// <returns></returns>
+ public static bool HasActiveConnection(Thread thread)
+ {
+ return _connectionPool.HasActiveConnection(thread);
+ }
+
+ /// <summary>
/// This method is for debugging purposes only, do not change/modify the
/// Thread or SqlCeConnection objects
/// </summary>
@@ -346,6 +364,19 @@
}
/// <summary>
+ /// Returns true if the connection pool has an active connection for the provided thread
+ /// </summary>
+ /// <param name="thread"></param>
+ /// <returns></returns>
+ public bool HasActiveConnection(Thread thread)
+ {
+ lock (_objLock)
+ {
+ return _activeConnections.ContainsKey(thread);
+ }
+ }
+
+ /// <summary>
/// Opens an SqlCeConnection for the current thread. If a connection already exists for the
/// current thread, that SqlCeConnection is used.
/// </summary>
@@ -371,19 +402,20 @@
if (_activeConnections.ContainsKey(threadCurrent))
{
- _log.DebugFormat("Open : The current thread {0} has an assigned connection", threadCurrent.Name);
+ _log.DebugFormat("Open : The current thread '{0}' with ThreadId={1} has an assigned connection",
+ threadCurrent.Name, threadCurrent.ManagedThreadId);
sqlConn = _activeConnections[threadCurrent];
}
else if (_pooledConnectionsStack.Count > 0)
{
- _log.DebugFormat("Open : The number of pooled connections={0}, assigning thread {1} a pooled connection",
- _pooledConnectionsStack.Count, threadCurrent.Name);
+ _log.DebugFormat("Open : The number of pooled connections={0}, assigning thread '{1}' with ThreadId={2} a pooled connection",
+ _pooledConnectionsStack.Count, threadCurrent.Name, threadCurrent.ManagedThreadId);
sqlConn = _pooledConnectionsStack.Pop();
}
else
{
- _log.DebugFormat("Open : The number of pooled connections={0}, assigning thread {1} a new connection",
- _pooledConnectionsStack.Count, threadCurrent.Name);
+ _log.DebugFormat("Open : The number of pooled connections={0}, assigning thread '{1}' with ThreadId={2} a new connection",
+ _pooledConnectionsStack.Count, threadCurrent.Name, threadCurrent.ManagedThreadId);
sqlConn = new SqlCeConnection(_connectionString);
}
_activeConnections[threadCurrent] = sqlConn;
@@ -400,8 +432,8 @@
_log.DebugFormat("Open : There are {0} connections open and {1} pooled connections",
OpenedConnectionsCount, PooledConnectionsCount);
- _log.DebugFormat("Open : Successfully opened connection for thread '{0}' in {1} ms",
- threadCurrent.Name, sw.ElapsedMilliseconds);
+ _log.DebugFormat("Open : Successfully opened connection for thread '{0}' with ThreadId={1} in {2} ms",
+ threadCurrent.Name, threadCurrent.ManagedThreadId, sw.ElapsedMilliseconds);
}
return sqlConn;
}
@@ -460,11 +492,15 @@
}
else
{
- _log.DebugFormat("Close : Could not close connection for thread '{0}', connection does not exist", threadCurrent.Name);
+ _log.DebugFormat("Close : Could not close connection for thread '{0}' with ThreadID={1}, connection does not exist",
+ threadCurrent.Name, threadCurrent.ManagedThreadId);
}
- _log.DebugFormat("Close : There are {0} connections open and {1} pooled connections", OpenedConnectionsCount, PooledConnectionsCount);
- _log.DebugFormat("Close : completed in {0} ms", sw.ElapsedMilliseconds);
+ if (_log.IsDebugEnabled)
+ {
+ _log.DebugFormat("Close : There are {0} connections open and {1} pooled connections", OpenedConnectionsCount, PooledConnectionsCount);
+ _log.DebugFormat("Close : completed in {0} ms", sw.ElapsedMilliseconds);
+ }
return returnVal;
}
}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2008-02-19 22:55:01 UTC (rev 116)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2008-02-21 19:46:11 UTC (rev 117)
@@ -564,7 +564,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
@@ -702,7 +702,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|