本文整理汇总了C#中System.Data.ProviderBase.DbConnectionInternal类的典型用法代码示例。如果您正苦于以下问题:C# DbConnectionInternal类的具体用法?C# DbConnectionInternal怎么用?C# DbConnectionInternal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbConnectionInternal类属于System.Data.ProviderBase命名空间,在下文中一共展示了DbConnectionInternal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateMetaDataFactory
protected override DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory)
{
cacheMetaDataFactory = false;
OleDbConnectionInternal internal2 = (OleDbConnectionInternal) internalConnection;
OleDbConnection connection = internal2.Connection;
NameValueCollection section = (NameValueCollection) System.Configuration.PrivilegedConfigurationManager.GetSection("system.data.oledb");
Stream xMLStream = null;
string dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 0x60) as string;
if (section != null)
{
string[] values = null;
string name = null;
if (dataSourcePropertyValue != null)
{
name = dataSourcePropertyValue + ":MetaDataXml";
values = section.GetValues(name);
}
if (values == null)
{
name = "defaultMetaDataXml";
values = section.GetValues(name);
}
if (values != null)
{
xMLStream = ADP.GetXmlStreamFromValues(values, name);
}
}
if (xMLStream == null)
{
xMLStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.OleDb.OleDbMetaData.xml");
cacheMetaDataFactory = true;
}
return new OleDbMetaDataFactory(xMLStream, internal2.ServerVersion, internal2.ServerVersion, internal2.GetSchemaRowsetInformation());
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:OleDbConnectionFactory.cs
示例2: CreateMetaDataFactory
override protected DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory){
Debug.Assert (internalConnection != null,"internalConnection may not be null.");
cacheMetaDataFactory = false;
OdbcConnection odbcOuterConnection = ((OdbcConnectionOpen)internalConnection).OuterConnection;
Debug.Assert(odbcOuterConnection != null,"outer connection may not be null.");
NameValueCollection settings = (NameValueCollection)PrivilegedConfigurationManager.GetSection("system.data.odbc");
Stream XMLStream =null;
// get the DBMS Name
object driverName = null;
string stringValue = odbcOuterConnection.GetInfoStringUnhandled(ODBC32.SQL_INFO.DRIVER_NAME);
if (stringValue != null) {
driverName = stringValue;
}
if (settings != null){
string [] values = null;
string metaDataXML = null;
// first try to get the provider specific xml
// if driver name is not supported we can't build the settings key needed to
// get the provider specific XML path
if (driverName != null){
metaDataXML = ((string)driverName) + _MetaData;
values = settings.GetValues(metaDataXML);
}
// if we did not find provider specific xml see if there is new default xml
if (values == null) {
metaDataXML = _defaultMetaDataXml;
values = settings.GetValues(metaDataXML);
}
// If there is an XML file get it
if (values != null) {
XMLStream = ADP.GetXmlStreamFromValues(values,metaDataXML);
}
}
// use the embedded xml if the user did not over ride it
if (XMLStream == null){
XMLStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.Odbc.OdbcMetaData.xml");
cacheMetaDataFactory = true;
}
Debug.Assert (XMLStream != null,"XMLstream may not be null.");
String versionString = odbcOuterConnection.GetInfoStringUnhandled(ODBC32.SQL_INFO.DBMS_VER);
return new OdbcMetaDataFactory (XMLStream,
versionString,
versionString,
odbcOuterConnection);
}
开发者ID:uQr,项目名称:referencesource,代码行数:58,代码来源:OdbcConnectionFactory.cs
示例3: CreateMetaDataFactory
override protected DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory){
Debug.Assert (internalConnection != null,"internalConnection may not be null.");
cacheMetaDataFactory = false;
OleDbConnectionInternal oleDbInternalConnection = (OleDbConnectionInternal) internalConnection;
OleDbConnection oleDbOuterConnection = oleDbInternalConnection.Connection;
Debug.Assert(oleDbOuterConnection != null,"outer connection may not be null.");
NameValueCollection settings = (NameValueCollection)PrivilegedConfigurationManager.GetSection("system.data.oledb");
Stream XMLStream =null;
String providerFileName = oleDbOuterConnection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo,ODB.DBPROP_PROVIDERFILENAME) as string;
if (settings != null){
string [] values = null;
string metaDataXML = null;
// first try to get the provider specific xml
// if providerfilename is not supported we can't build the settings key needed to
// get the provider specific XML path
if (providerFileName != null){
metaDataXML = providerFileName + _metaDataXml;
values = settings.GetValues(metaDataXML);
}
// if we did not find provider specific xml see if there is new default xml
if (values == null) {
metaDataXML =_defaultMetaDataXml;
values = settings.GetValues(metaDataXML);
}
// If there is new XML get it
if (values != null) {
XMLStream = ADP.GetXmlStreamFromValues(values,metaDataXML);
}
}
// if the xml was not obtained from machine.config use the embedded XML resource
if (XMLStream == null) {
XMLStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.OleDb.OleDbMetaData.xml");
cacheMetaDataFactory = true;
}
Debug.Assert (XMLStream != null,"XMLstream may not be null.");
// using the ServerVersion as the NormalizedServerVersion. Doing this for two reasons
// 1) The Spec for DBPROP_DBMSVER normalizes the ServerVersion
// 2) for OLE DB its the only game in town
return new OleDbMetaDataFactory (XMLStream,
oleDbInternalConnection.ServerVersion,
oleDbInternalConnection.ServerVersion,
oleDbInternalConnection.GetSchemaRowsetInformation());
}
开发者ID:uQr,项目名称:referencesource,代码行数:55,代码来源:OleDbConnectionFactory.cs
示例4: ConnectionString_Set
private void ConnectionString_Set(DbConnectionPoolKey key)
{
DbConnectionOptions connectionOptions = null;
System.Data.ProviderBase.DbConnectionPoolGroup poolGroup = ConnectionFactory.GetConnectionPoolGroup(key, null, ref connectionOptions);
DbConnectionInternal connectionInternal = InnerConnection;
bool flag = connectionInternal.AllowSetConnectionString;
if (flag)
{
flag = SetInnerConnectionFrom(DbConnectionClosedBusy.SingletonInstance, connectionInternal);
if (flag)
{
_userConnectionOptions = connectionOptions;
_poolGroup = poolGroup;
_innerConnection = DbConnectionClosedNeverOpened.SingletonInstance;
}
}
if (!flag)
{
throw ADP.OpenConnectionPropertySet(ADP.ConnectionString, connectionInternal.State);
}
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:21,代码来源:SqlConnectionHelper.cs
示例5: CreateMetaDataFactory
protected override DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory)
{
cacheMetaDataFactory = false;
OdbcConnection outerConnection = ((OdbcConnectionOpen) internalConnection).OuterConnection;
NameValueCollection section = (NameValueCollection) System.Configuration.PrivilegedConfigurationManager.GetSection("system.data.odbc");
Stream xMLStream = null;
object obj2 = null;
string infoStringUnhandled = outerConnection.GetInfoStringUnhandled(ODBC32.SQL_INFO.DRIVER_NAME);
if (infoStringUnhandled != null)
{
obj2 = infoStringUnhandled;
}
if (section != null)
{
string[] values = null;
string name = null;
if (obj2 != null)
{
name = ((string) obj2) + ":MetaDataXml";
values = section.GetValues(name);
}
if (values == null)
{
name = "defaultMetaDataXml";
values = section.GetValues(name);
}
if (values != null)
{
xMLStream = ADP.GetXmlStreamFromValues(values, name);
}
}
if (xMLStream == null)
{
xMLStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.Odbc.OdbcMetaData.xml");
cacheMetaDataFactory = true;
}
string serverVersion = outerConnection.GetInfoStringUnhandled(ODBC32.SQL_INFO.DBMS_VER);
return new OdbcMetaDataFactory(xMLStream, serverVersion, serverVersion, outerConnection);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:OdbcConnectionFactory.cs
示例6: SetInnerConnectionFrom
override internal bool SetInnerConnectionFrom(DbConnection owningObject, DbConnectionInternal to, DbConnectionInternal from) {
SqlConnection c = (owningObject as SqlConnection);
if (null != c) {
return c.SetInnerConnectionFrom(to, from);
}
return false;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:SqlConnectionFactory.cs
示例7: ReplaceConnection
/// <summary>
/// Creates a new connection to replace an existing connection
/// </summary>
/// <param name="owningObject">Outer connection that currently owns <paramref name="oldConnection"/></param>
/// <param name="userOptions">Options used to create the new connection</param>
/// <param name="oldConnection">Inner connection that will be replaced</param>
/// <returns>A new inner connection that is attached to the <paramref name="owningObject"/></returns>
internal DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
{
DbConnectionInternal newConnection = UserCreateRequest(owningObject, userOptions, oldConnection);
if (newConnection != null)
{
PrepareConnection(owningObject, newConnection);
oldConnection.PrepareForReplaceConnection();
oldConnection.DeactivateConnection();
oldConnection.Dispose();
}
return newConnection;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:21,代码来源:DbConnectionPool.cs
示例8: TryGetConnection
private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection)
{
DbConnectionInternal obj = null;
if (null == obj)
{
Interlocked.Increment(ref _waitCount);
do
{
int waitResult = BOGUS_HANDLE;
try
{
try
{
}
finally
{
waitResult = WaitHandle.WaitAny(_waitHandles.GetHandles(allowCreate), unchecked((int)waitForMultipleObjectsTimeout));
}
// From the WaitAny docs: "If more than one object became signaled during
// the call, this is the array index of the signaled object with the
// smallest index value of all the signaled objects." This is important
// so that the free object signal will be returned before a creation
// signal.
switch (waitResult)
{
case WaitHandle.WaitTimeout:
Interlocked.Decrement(ref _waitCount);
connection = null;
return false;
case ERROR_HANDLE:
// Throw the error that PoolCreateRequest stashed.
Interlocked.Decrement(ref _waitCount);
throw TryCloneCachedException();
case CREATION_HANDLE:
try
{
obj = UserCreateRequest(owningObject, userOptions);
}
catch
{
if (null == obj)
{
Interlocked.Decrement(ref _waitCount);
}
throw;
}
finally
{
// Ensure that we release this waiter, regardless
// of any exceptions that may be thrown.
if (null != obj)
{
Interlocked.Decrement(ref _waitCount);
}
}
if (null == obj)
{
// If we were not able to create an object, check to see if
// we reached MaxPoolSize. If so, we will no longer wait on
// the CreationHandle, but instead wait for a free object or
// the timeout.
if (Count >= MaxPoolSize && 0 != MaxPoolSize)
{
if (!ReclaimEmancipatedObjects())
{
// modify handle array not to wait on creation mutex anymore
Debug.Assert(2 == CREATION_HANDLE, "creation handle changed value");
allowCreate = false;
}
}
}
break;
case SEMAPHORE_HANDLE:
//
// guaranteed available inventory
//
Interlocked.Decrement(ref _waitCount);
obj = GetFromGeneralPool();
if ((obj != null) && (!obj.IsConnectionAlive()))
{
DestroyObject(obj);
obj = null; // Setting to null in case creating a new object fails
if (onlyOneCheckConnection)
{
if (_waitHandles.CreationSemaphore.WaitOne(unchecked((int)waitForMultipleObjectsTimeout)))
{
try
{
obj = UserCreateRequest(owningObject, userOptions);
}
//.........这里部分代码省略.........
开发者ID:ChuangYang,项目名称:corefx,代码行数:101,代码来源:DbConnectionPool.cs
示例9: DestroyObject
internal void DestroyObject(DbConnectionInternal obj)
{
// A connection with a delegated transaction cannot be disposed of
// until the delegated transaction has actually completed. Instead,
// we simply leave it alone; when the transaction completes, it will
// come back through PutObjectFromTransactedPool, which will call us
// again.
bool removed = false;
lock (_objectList)
{
removed = _objectList.Remove(obj);
Debug.Assert(removed, "attempt to DestroyObject not in list");
_totalObjects = _objectList.Count;
}
if (removed)
{
}
obj.Dispose();
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:20,代码来源:DbConnectionPool.cs
示例10: CreateObject
private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
{
DbConnectionInternal newObj = null;
try
{
newObj = _connectionFactory.CreatePooledConnection(this, owningObject, _connectionPoolGroup.ConnectionOptions, _connectionPoolGroup.PoolKey, userOptions);
if (null == newObj)
{
throw ADP.InternalError(ADP.InternalErrorCode.CreateObjectReturnedNull); // CreateObject succeeded, but null object
}
if (!newObj.CanBePooled)
{
throw ADP.InternalError(ADP.InternalErrorCode.NewObjectCannotBePooled); // CreateObject succeeded, but non-poolable object
}
newObj.PrePush(null);
lock (_objectList)
{
if ((oldConnection != null) && (oldConnection.Pool == this))
{
_objectList.Remove(oldConnection);
}
_objectList.Add(newObj);
_totalObjects = _objectList.Count;
}
// If the old connection belonged to another pool, we need to remove it from that
if (oldConnection != null)
{
var oldConnectionPool = oldConnection.Pool;
if (oldConnectionPool != null && oldConnectionPool != this)
{
Debug.Assert(oldConnectionPool._state == State.ShuttingDown, "Old connections pool should be shutting down");
lock (oldConnectionPool._objectList)
{
oldConnectionPool._objectList.Remove(oldConnection);
oldConnectionPool._totalObjects = oldConnectionPool._objectList.Count;
}
}
}
// Reset the error wait:
_errorWait = ERROR_WAIT_DEFAULT;
}
catch (Exception e)
{
if (!ADP.IsCatchableExceptionType(e))
{
throw;
}
newObj = null; // set to null, so we do not return bad new object
// Failed to create instance
_resError = e;
// Make sure the timer starts even if ThreadAbort occurs after setting the ErrorEvent.
// timer allocation has to be done out of CER block
Timer t = new Timer(new TimerCallback(this.ErrorCallback), null, Timeout.Infinite, Timeout.Infinite);
bool timerIsNotDisposed;
try { }
finally
{
_waitHandles.ErrorEvent.Set();
_errorOccurred = true;
// Enable the timer.
// Note that the timer is created to allow periodic invocation. If ThreadAbort occurs in the middle of ErrorCallback,
// the timer will restart. Otherwise, the timer callback (ErrorCallback) destroys the timer after resetting the error to avoid second callback.
_errorTimer = t;
timerIsNotDisposed = t.Change(_errorWait, _errorWait);
}
Debug.Assert(timerIsNotDisposed, "ErrorCallback timer has been disposed");
if (30000 < _errorWait)
{
_errorWait = 60000;
}
else
{
_errorWait *= 2;
}
throw;
}
return newObj;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:87,代码来源:DbConnectionPool.cs
示例11: PutObject
internal void PutObject(DbConnectionInternal obj, object owningObject)
{
Debug.Assert(null != obj, "null obj?");
// Once a connection is closing (which is the state that we're in at
// this point in time) you cannot delegate a transaction to or enlist
// a transaction in it, so we can correctly presume that if there was
// not a delegated or enlisted transaction to start with, that there
// will not be a delegated or enlisted transaction once we leave the
// lock.
lock (obj)
{
// Calling PrePush prevents the object from being reclaimed
// once we leave the lock, because it sets _pooledCount such
// that it won't appear to be out of the pool. What that
// means, is that we're now responsible for this connection:
// it won't get reclaimed if we drop the ball somewhere.
obj.PrePush(owningObject);
}
DeactivateObject(obj);
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:24,代码来源:DbConnectionPool.cs
示例12: CreateMetaDataFactory
protected virtual DbMetaDataFactory CreateMetaDataFactory (DbConnectionInternal internalConnection)
{
throw new NotImplementedException ();
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:DbConnectionFactory.cs
示例13: PutNewObject
internal void PutNewObject(DbConnectionInternal obj)
{
Debug.Assert(null != obj, "why are we adding a null object to the pool?");
// Debug.Assert(obj.CanBePooled, "non-poolable object in pool");
_stackNew.Push(obj);
_waitHandles.PoolSemaphore.Release(1);
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:DbConnectionPool.cs
示例14: SetInnerConnectionEvent
internal void SetInnerConnectionEvent(System.Data.ProviderBase.DbConnectionInternal to)
{
ConnectionState originalState = this._innerConnection.State & ConnectionState.Open;
ConnectionState currentState = to.State & ConnectionState.Open;
if ((originalState != currentState) && (currentState == ConnectionState.Closed))
{
this._closeCount++;
}
this._innerConnection = to;
if ((originalState == ConnectionState.Closed) && (ConnectionState.Open == currentState))
{
this.OnStateChange(System.Data.ProviderBase.DbConnectionInternal.StateChangeOpen);
}
else if ((ConnectionState.Open == originalState) && (currentState == ConnectionState.Closed))
{
this.OnStateChange(System.Data.ProviderBase.DbConnectionInternal.StateChangeClosed);
}
else if (originalState != currentState)
{
this.OnStateChange(new StateChangeEventArgs(originalState, currentState));
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:OracleConnection.cs
示例15: UserCreateRequest
private DbConnectionInternal UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection = null)
{
// called by user when they were not able to obtain a free object but
// instead obtained creation mutex
DbConnectionInternal obj = null;
if (ErrorOccurred)
{
throw TryCloneCachedException();
}
else
{
if ((oldConnection != null) || (Count < MaxPoolSize) || (0 == MaxPoolSize))
{
// If we have an odd number of total objects, reclaim any dead objects.
// If we did not find any objects to reclaim, create a new one.
if ((oldConnection != null) || (Count & 0x1) == 0x1 || !ReclaimEmancipatedObjects())
obj = CreateObject(owningObject, userOptions, oldConnection);
}
return obj;
}
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:22,代码来源:DbConnectionPool.cs
示例16: SetInnerConnectionTo
internal void SetInnerConnectionTo(System.Data.ProviderBase.DbConnectionInternal to)
{
this._innerConnection = to;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:OracleConnection.cs
示例17: DeactivateObject
private void DeactivateObject(DbConnectionInternal obj)
{
obj.DeactivateConnection();
bool returnToGeneralPool = false;
bool destroyObject = false;
if (obj.IsConnectionDoomed)
{
// the object is not fit for reuse -- just dispose of it.
destroyObject = true;
}
else
{
// NOTE: constructor should ensure that current state cannot be State.Initializing, so it can only
// be State.Running or State.ShuttingDown
Debug.Assert(_state == State.Running || _state == State.ShuttingDown);
lock (obj)
{
// A connection with a delegated transaction cannot currently
// be returned to a different customer until the transaction
// actually completes, so we send it into Stasis -- the SysTx
// transaction object will ensure that it is owned (not lost),
// and it will be certain to put it back into the pool.
if (_state == State.ShuttingDown)
{
// connection is being closed and the pool has been marked as shutting
// down, so destroy this object.
destroyObject = true;
}
else
{
if (obj.CanBePooled)
{
// We must put this connection into the transacted pool
// while inside a lock to prevent a race condition with
// the transaction asynchronously completing on a second
// thread.
// return to general pool
returnToGeneralPool = true;
}
else
{
// object is not fit for reuse -- just dispose of it
destroyObject = true;
}
}
}
}
if (returnToGeneralPool)
{
// Only push the connection into the general pool if we didn't
// already push it onto the transacted pool, put it into stasis,
// or want to destroy it.
Debug.Assert(destroyObject == false);
PutNewObject(obj);
}
else if (destroyObject)
{
DestroyObject(obj);
QueuePoolCreateRequest();
}
//-------------------------------------------------------------------------------------
// postcondition
// ensure that the connection was processed
Debug.Assert(
returnToGeneralPool == true || destroyObject == true);
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:74,代码来源:DbConnectionPool.cs
示例18: TryGetConnection
internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, out DbConnectionInternal connection)
{
Debug.Assert(null != owningConnection, "null owningConnection?");
DbConnectionPoolGroup poolGroup;
DbConnectionPool connectionPool;
connection = null;
// Work around race condition with clearing the pool between GetConnectionPool obtaining pool
// and GetConnection on the pool checking the pool state. Clearing the pool in this window
// will switch the pool into the ShuttingDown state, and GetConnection will return null.
// There is probably a better solution involving locking the pool/group, but that entails a major
// re-design of the connection pooling synchronization, so is post-poned for now.
// Use retriesLeft to prevent CPU spikes with incremental sleep
// start with one msec, double the time every retry
// max time is: 1 + 2 + 4 + ... + 2^(retries-1) == 2^retries -1 == 1023ms (for 10 retries)
int retriesLeft = 10;
int timeBetweenRetriesMilliseconds = 1;
do
{
poolGroup = GetConnectionPoolGroup(owningConnection);
// Doing this on the callers thread is important because it looks up the WindowsIdentity from the thread.
connectionPool = GetConnectionPool(owningConnection, poolGroup);
if (null == connectionPool)
{
// If GetConnectionPool returns null, we can be certain that
// this connection should not be pooled via DbConnectionPool
// or have a disabled pool entry.
poolGroup = GetConnectionPoolGroup(owningConnection); // previous entry have been disabled
if (retry != null)
{
Task<DbConnectionInternal> newTask;
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
lock (s_pendingOpenNonPooled)
{
// look for an available task slot (completed or empty)
int idx;
for (idx = 0; idx < s_pendingOpenNonPooled.Length; idx++)
{
Task task = s_pendingOpenNonPooled[idx];
if (task == null)
{
s_pendingOpenNonPooled[idx] = GetCompletedTask();
break;
}
else if (task.IsCompleted)
{
break;
}
}
// if didn't find one, pick the next one in round-robbin fashion
if (idx == s_pendingOpenNonPooled.Length)
{
idx = s_pendingOpenNonPooledNext++ % s_pendingOpenNonPooled.Length;
}
// now that we have an antecedent task, schedule our work when it is completed.
// If it is a new slot or a compelted task, this continuation will start right away.
newTask = s_pendingOpenNonPooled[idx].ContinueWith((_) =>
{
var newConnection = CreateNonPooledConnection(owningConnection, poolGroup, userOptions);
if ((oldConnection != null) && (oldConnection.State == ConnectionState.Open))
{
oldConnection.PrepareForReplaceConnection();
oldConnection.Dispose();
}
return newConnection;
}, cancellationTokenSource.Token, TaskContinuationOptions.LongRunning, TaskScheduler.Default);
// Place this new task in the slot so any future work will be queued behind it
s_pendingOpenNonPooled[idx] = newTask;
}
// Set up the timeout (if needed)
if (owningConnection.ConnectionTimeout > 0)
{
int connectionTimeoutMilliseconds = owningConnection.ConnectionTimeout * 1000;
cancellationTokenSource.CancelAfter(connectionTimeoutMilliseconds);
}
// once the task is done, propagate the final results to the original caller
newTask.ContinueWith((task) =>
{
cancellationTokenSource.Dispose();
if (task.IsCanceled)
{
retry.TrySetException(ADP.ExceptionWithStackTrace(ADP.NonPooledOpenTimeout()));
}
else if (task.IsFaulted)
{
retry.TrySetException(task.Exception.InnerException);
}
else
{
if (!retry.TrySetResult(task.Result))
{
//.........这里部分代码省略.........
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:DbConnectionFactory.cs
示例19: SetInnerConnectionFrom
abstract internal bool SetInnerConnectionFrom(DbConnection owningObject, DbConnectionInternal to, DbConnectionInternal from);
开发者ID:er0dr1guez,项目名称:corefx,代码行数:1,代码来源:DbConnectionFactory.cs
示例20: PrepareConnection
private void PrepareConnection(DbConnection owningObject, DbConnectionInternal obj)
{
lock (obj)
{ // Protect against Clear and ReclaimEmancipatedObjects, which call IsEmancipated, which is affected by PrePush and PostPop
obj.PostPop(owningObject);
}
try
{
obj.ActivateConnection();
}
catch
{
// if Activate throws an exception
// put it back in the pool or have it properly disposed of
this.PutObject(obj, owningObject);
throw;
}
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:18,代码来源:DbConnectionPool.cs
注:本文中的System.Data.ProviderBase.DbConnectionInternal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论