/// <summary> /// Asynchronusly retrieve a SHA1 hash. The XSHA1 command is non-standard /// and not guaranteed to work. /// </summary> /// <param name="client">FtpClient Object</param> /// <param name="path">Full or relative path to remote file</param> /// <param name="callback">AsyncCallback</param> /// <param name="state">State Object</param> /// <returns>IAsyncResult</returns> public static IAsyncResult BeginGetXSHA1(this FtpClient client, string path, AsyncCallback callback, object state) { AsyncGetXSHA1 func = new AsyncGetXSHA1(client.GetXSHA1); IAsyncResult ar = func.BeginInvoke(path, callback, state); ; lock (m_asyncmethods) { m_asyncmethods.Add(ar, func); } return ar; }
/// <summary> /// Asynchronusly retrieve a SHA1 hash. The XSHA1 command is non-standard /// and not guaranteed to work. /// </summary> /// <param name="client">FtpClient Object</param> /// <param name="path">Full or relative path to remote file</param> /// <param name="callback">AsyncCallback</param> /// <param name="state">State Object</param> /// <returns>IAsyncResult</returns> public static IAsyncResult BeginGetXSHA1(this FtpClient client, string path, AsyncCallback callback, object state) { AsyncGetXSHA1 func = new AsyncGetXSHA1(client.GetXSHA1); IAsyncResult ar = func.BeginInvoke(path, callback, state);; lock (m_asyncmethods) { m_asyncmethods.Add(ar, func); } return(ar); }
/// <summary> /// Begins an asynchronous operation to retrieve a SHA1 hash. The XSHA1 command is non-standard /// and not guaranteed to work. /// </summary> /// <param name="path">Full or relative path to remote file</param> /// <param name="callback">AsyncCallback</param> /// <param name="state">State Object</param> /// <returns>IAsyncResult</returns> public IAsyncResult BeginGetXSHA1(string path, AsyncCallback callback, object state) { var func = new AsyncGetXSHA1(GetXSHA1); IAsyncResult ar; lock (m_asyncmethods) { ar = func.BeginInvoke(path, callback, state); m_asyncmethods.Add(ar, func); } return(ar); }
/// <summary> /// Ends an asynchronous call to BeginGetXSHA1() /// </summary> /// <param name="ar">IAsyncResult returned from BeginGetXSHA1()</param> /// <returns>The SHA-1 hash of the specified file.</returns> public static string EndGetXSHA1(IAsyncResult ar) { AsyncGetXSHA1 func = null; lock (m_asyncmethods) { if (!m_asyncmethods.ContainsKey(ar)) { throw new InvalidOperationException("The specified IAsyncResult was not found in the collection."); } func = m_asyncmethods[ar]; m_asyncmethods.Remove(ar); } return(func.EndInvoke(ar)); }