async Task AddToQueueAsync(Visit visit, AdditionInfo info = null) { var entity = new PromiseEntity(visit); var entry = new PromiseEntry() { Visit = visit, Id = entity.Id = Guid.NewGuid(), LastRequestTime = entity.LastRequestTime = entity.CreateTime = DateTime.Now, RetryInternvals = entity.RetryInternvals = 1000, RequestCount = entity.RequestCount = 1 }; if (info != null) { entity.Category = info.Category; entity.BusinessId = info.BusinessId; } await this.Store.CreateAsync(entity); lock (this) { _NotCompletes.Enqueue(entry); if (_Thread == null) { _Thread = new Thread(new ThreadStart(this.Loop)); _Thread.Start(); } } }
public void Request(AjaxOptions opts, AdditionInfo info = null) { opts.error = (ex, visit) => { this.AddToQueueAsync(visit, info).Start(); return(true); }; Ajax.Request(opts); }