/// <summary> /// Performs a search request /// </summary> /// <param name="Timeout">Timeout in milliseconds.</param> /// <exception cref="TimeoutException">If timeout occurs.</exception> public SearchResultEventArgs Search(int Timeout) { ManualResetEvent Done = new ManualResetEvent(false); SearchResultEventArgs e = null; try { this.SendSearchRequest((sender, e2) => { e = e2; Done.Set(); }, null); if (!Done.WaitOne(Timeout)) { throw new TimeoutException(); } } finally { Done.Dispose(); } if (!e.Ok) { throw e.StanzaError; } return(e); }
private void CallResponseMethod(SearchResultEventHandler Callback, object State, List <Dictionary <string, string> > Records, IqResultEventArgs e) { SearchResultEventArgs e2 = new SearchResultEventArgs(Records.ToArray(), e); e2.State = State; if (Callback != null) { try { Callback(this.client, e2); } catch (Exception ex) { this.client.Exception(ex); } } }
private async Task CallResponseMethod(SearchResultEventHandler Callback, object State, List <Dictionary <string, string> > Records, Field[] Headers, IqResultEventArgs e) { SearchResultEventArgs e2 = new SearchResultEventArgs(Records.ToArray(), Headers, e) { State = State }; if (!(Callback is null)) { try { await Callback(this.client, e2); } catch (Exception ex) { this.client.Exception(ex); } } }