/// <summary> /// Registers the application usage asynchronous. /// </summary> /// <param name="item">The item.</param> /// <param name="act">The act.</param> public void RegisterAppUsageAsync(IAppContract item, Action <IAppContract> act = null) { IAppContract res = null; using (var wrk = new BackgroundWorker()) { wrk.DoWork += (sender, args) => { try { res = RegisterAppUsage(item); } catch (Exception ex) { wrk.Dispose(); Logger.Error(ex.GetCombinedMessages()); } }; wrk.RunWorkerCompleted += (s, e) => { wrk.Dispose(); if (act != null) { act(res); } }; wrk.RunWorkerAsync(); } }
/// <summary> /// Registers the application usage. /// </summary> /// <param name="item">The item.</param> /// <returns>IAppContract.</returns> public IAppContract RegisterAppUsage(IAppContract item) { var clt = CreateClient(); try { return(clt.RegisterAppUsage(item.Zip()) .Unzip <AppContract>()); } finally { CloseClient(clt); } }