Inheritance: ConnectionScopeBase, IDisposable
Esempio n. 1
0
        /// <summary>
        /// Creates a new <see cref="Thread"/> object and copies
        /// the current <see cref="ConnectionScope"/> parameters.
        /// </summary>
        /// <param name="start">A delegate specifying which method to run
        /// when the <see cref="Thread"/> is started.</param>
        /// <returns>Returns a new <see cref="Thread"/> object.</returns>
        public static Thread NewThread(ThreadStart start)
        {
            ConnectionScope scope = ConnectionScope.Current;

            Thread t = new Thread(delegate()
            {
                ConnectionScope.Copy(scope);
                start();
            });

            return(t);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new <see cref="Thread"/> object and copies
        /// the current <see cref="ConnectionScope"/> parameters.
        /// </summary>
        /// <param name="start">A delegate specifying which method to run
        /// when the <see cref="Thread"/> is started.</param>
        /// <returns>Returns a new <see cref="Thread"/> object.</returns>
        public static Thread NewThread(ParameterizedThreadStart start)
        {
            ConnectionScope scope = ConnectionScope.Current;

            Thread t = new Thread(delegate(Object obj)
            {
                ConnectionScope.Copy(scope);
                start(obj);
            });

            return(t);
        }
Esempio n. 3
0
		/// <summary>
		/// Copies the values from the specified <paramref name="scope"/> object
		/// to the <see cref="ConnectionScope"/> used by the current thread.
		/// </summary>
		/// <param name="scope">A <see cref="ConnectionScope"/> object.</param>
		private static void Copy(ConnectionScope scope)
		{
			ConnectionScope newScope = ConnectionScope.Current;
			newScope.ConnectionStringKey = scope.ConnectionStringKey;
			newScope.DynamicConnectionString = scope.DynamicConnectionString;
            newScope.TransactionManager = scope.TransactionManager;
            newScope.DataProvider = scope.DataProvider;
		}