当前位置: 首页>>代码示例>>C#>>正文


C# this.Close方法代码示例

本文整理汇总了C#中this.Close方法的典型用法代码示例。如果您正苦于以下问题:C# this.Close方法的具体用法?C# this.Close怎么用?C# this.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteProcWithParamsDT

        /// <summary>
        /// Execute Stored Procedure with the Parameters passed
        /// </summary>
        /// <param name="Conn"></param>
        /// <param name="procname"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable ExecuteProcWithParamsDT(this SqlConnection Conn, string procname, Hashtable parameters)
        {
            DataSet dataSet;
            try
            {
                SqlDataAdapter dataAdaptor = new SqlDataAdapter();
                dataAdaptor.SelectCommand = new SqlCommand(procname, Conn);
                dataAdaptor.SelectCommand.CommandType = CommandType.StoredProcedure;
                if (parameters != null)
                    foreach (DictionaryEntry de in parameters)
                    {
                        SqlParameter sp = new SqlParameter(de.Key.ToString(), de.Value.ToString());
                        dataAdaptor.SelectCommand.Parameters.Add(sp);
                    }

                dataSet = new DataSet();
                dataAdaptor.Fill(dataSet, "table");
                Conn.Close();
                return dataSet.Tables["table"];
            }
            catch (Exception ex)
            {
                dataSet = null;
                Conn.Close();
                return null;
            }
            finally
            {
                Conn.Close();
                dataSet = null;
            }
        }
开发者ID:eacodes,项目名称:IHSFramework,代码行数:39,代码来源:DBExtensions.cs

示例2: Dispose

 public static void Dispose(this ICommunicationObject communicationObject, TimeSpan? closeTimeout)
 {
     bool abort = true;
     try
     {
         if (closeTimeout.HasValue)
         {
             communicationObject.Close(closeTimeout.Value);
         }
         else
         {
             communicationObject.Close();
         }
         abort = false;
     }
     catch (Exception e) when (e is TimeoutException || e is CommunicationException)
     {
     }
     finally
     {
         if (abort)
         {
             Trace.TraceWarning($"{nameof(CommunicationObjectExtensionMethods)}.{nameof(Dispose)}: The communication object is being aborted.");
             communicationObject.Abort();
         }
     }
 }
开发者ID:hjb417,项目名称:rabbitmq-wcf-transports,代码行数:27,代码来源:CommunicationObjectExtensionMethods.cs

示例3: CloseIfNotNull

 public static void CloseIfNotNull(this ICloseable closable)
 {
     if (closable != null) {
         if (closable is Component) {
             if ((Component)closable) {
                 closable.Close();
             }
         } else {
             closable.Close();
         }
     }
 }
开发者ID:rcd229,项目名称:Crystallize2D,代码行数:12,代码来源:ICloseable.cs

示例4: CloseDoc

 ///<summary>Forces a document to close.</summary>
 ///<remarks>This method works around Office issues.</remarks>
 public static void CloseDoc(this _Document doc)
 {
     try {
         doc.Close(ref dontSave, ref Missing, ref Missing);
         doc.Close(ref Missing, ref Missing, ref Missing);
     } catch (COMException) {
         try {
             doc.Close(ref dontSave, ref Missing, ref Missing);
             doc.Close(ref dontSave, ref Missing, ref Missing);
         } catch (COMException) { }
     }
 }
开发者ID:SyedArifulIslamEmon,项目名称:Billing,代码行数:14,代码来源:WordExport.cs

示例5: CloseAsync

 public static Task CloseAsync(this Logger target)
 {
     return Task.Factory.StartNew(()=>{
         target.Close();
         return;
     });
 }
开发者ID:zoetrope,项目名称:ReactiveRTM,代码行数:7,代码来源:Extension.generated.cs

示例6: ReadOne

		public static IDataReader ReadOne(this IDataReader reader, Action<IDataReader> action)
		{
			if (reader.Read())
				action(reader);
			reader.Close();
			return reader;
		}
开发者ID:andyliyuze,项目名称:POPForums,代码行数:7,代码来源:Extensions.cs

示例7: PrintToFile

 public static void PrintToFile(this FileStream fs, string content)
 {
     StreamWriter writer = new StreamWriter(fs);
     writer.WriteLine(content);
     writer.Close();
     fs.Close();
 }
开发者ID:divyang4481,项目名称:REM,代码行数:7,代码来源:Extensions.cs

示例8: smethod_7

 public static bool smethod_7(this TcpClient tcpClient_0, string string_0, int int_0, int int_1)
 {
     IAsyncResult asyncResult = tcpClient_0.BeginConnect(string_0, int_0, null, null);
     WaitHandle asyncWaitHandle = asyncResult.AsyncWaitHandle;
     bool result;
     try
     {
         if (asyncWaitHandle.WaitOne(int_1))
         {
             tcpClient_0.EndConnect(asyncResult);
             result = true;
         }
         else
         {
             tcpClient_0.Close();
             result = false;
         }
     }
     catch (SocketException)
     {
         result = false;
     }
     finally
     {
         asyncWaitHandle.Close();
     }
     return result;
 }
开发者ID:JohnDeerexx,项目名称:project-respawn,代码行数:28,代码来源:Class6.cs

示例9: SendWithTimeoutAfter

        public static async Task<int> SendWithTimeoutAfter(this UdpClient client, Byte[] list, int delay,
            CancellationTokenSource cancel) {
            if (client == null)
                throw new NullReferenceException();

            if (list == null)
                throw new ArgumentNullException("list");

            var task = client.SendAsync(list, list.Length);

            if (task.IsCompleted || (delay == Timeout.Infinite))
                return await task;

            await Task.WhenAny(task, Task.Delay(delay, cancel.Token)).ConfigureAwait(false);

            if (!task.IsCompleted) {
                client.Close();
                try {
                    return await task.ConfigureAwait(false);
                } catch (ObjectDisposedException) {
                    throw new TimeoutException("Send timed out.");
                }
            }

            cancel.Cancel(); // Cancel the timer! 
            return await task.ConfigureAwait(false);
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:27,代码来源:SocketExtensions.cs

示例10: Close

 public static void Close(this Solution sol, CloseOptions options)
 {
     var save = (options & CloseOptions.Save) == CloseOptions.Save;
     var wait = (options & CloseOptions.Wait) == CloseOptions.Wait;
     sol.Close(save);
     if (wait) WaitFor(null, () => sol.IsOpen == false, waitFor: TimeSpan.FromSeconds(20));
 }
开发者ID:modulexcite,项目名称:openwrap,代码行数:7,代码来源:DteExtensions.cs

示例11: CloseSafely

        /**--------------------------------------------------------------------------------------------------
        <summary> A SqlConnection extension method that closes a safely. </summary>

        <param name="con"> The con to act on. </param>

        <returns> . </returns>
        **/
        public static void CloseSafely(this DbConnection con)
        {
            if (con.State == ConnectionState.Open)
                con.Close();

            //return con;
        }
开发者ID:sheryever,项目名称:simple-access-orm,代码行数:14,代码来源:ConnectionExtension.cs

示例12: GetJObject

 public static CouchResponseObject GetJObject(this HttpWebResponse response)
 {
     var resp = new CouchResponseObject(JObject.Parse(response.GetResponseString()));
     resp.StatusCode = (int)response.StatusCode;
     response.Close();
     return resp;
 }
开发者ID:Ian1971,项目名称:LoveSeat,代码行数:7,代码来源:ResponseExtensionMethods.cs

示例13: SpecialClose

 public async static void SpecialClose(this Window window)
 {
     await window.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
     {
         window.Close();
     });
 }
开发者ID:h82258652,项目名称:Samples,代码行数:7,代码来源:WindowService.cs

示例14: SafeCloseClientSocket

        public static void SafeCloseClientSocket(this Socket client, ILogger logger)
        {
            if(client == null)
                return;

            if (!client.Connected)
                return;
            
            try
            {
                client.Shutdown(SocketShutdown.Both);
            }
            catch(ObjectDisposedException)
            {
            }
            catch(Exception e)
            {
                if(logger != null)
                    logger.LogError(e);
            }
            
            try
            {
                client.Close();
            }
            catch(ObjectDisposedException)
            {
            }
            catch(Exception e)
            {
                if(logger != null)
                    logger.LogError(e);
            }
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:34,代码来源:SocketEx.cs

示例15: CloseOrAbort

 /// <summary>
 /// Closes the <see cref="ICommunicationObject"/> if it's not in the Faulted state, but Aborts it otherwise.
 /// Additionally, if Close throws an expected exception, that exception is swallowed and the operation is Aborted.
 /// </summary>
 /// <param name="client">The <see cref="ICommunicationObject"/> on which <see cref="ICommunicationObject.Close()"/>
 /// or <see cref="ICommunicationObject.Abort()"/> will be called.</param>
 /// <remarks>For more details, see:
 /// http://msdn2.microsoft.com/en-us/library/aa355056.aspx
 /// http://msdn2.microsoft.com/en-us/library/aa354510.aspx
 /// http://bloggingabout.net/blogs/erwyn/archive/2006/12/09/WCF-Service-Proxy-Helper.aspx
 /// http://blogs.breezetraining.com.au/mickb/2006/12/19/GreatArticleOnWCF.aspx
 /// </remarks>
 public static void CloseOrAbort(this ICommunicationObject client)
 {
     if (client.State != CommunicationState.Faulted)
     {
         // client is in non-faulted state; we can attempt to Close it
         try
         {
             client.Close();
         }
         catch (CommunicationException)
         {
             client.Abort();
         }
         catch (TimeoutException)
         {
             client.Abort();
         }
         catch (Exception)
         {
             // unexpected exception--still Abort the client, but re-throw it
             client.Abort();
             throw;
         }
     }
     else
     {
         // client has already failed; have to abort
         client.Abort();
     }
 }
开发者ID:mattrudder,项目名称:mono-embed,代码行数:42,代码来源:CommunicationObjectUtility.cs


注:本文中的this.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。