public string GetMessage(int targetNumber, int?x) { var messageFormat = Message; if (messageFormat == null) { messageFormat = MaxCount != null && MaxCount.GetValue(x) == 1 ? DefaultMessageOneTarget : DefaultMessageMultipleTargets; } if (_owningCard != null) { messageFormat = String.Format("{0}: {1}", _owningCard, messageFormat); } if (MaxCount != null) { var maxNumber = MinCount.GetValue(x) == MaxCount.GetValue(x) ? MaxCount.GetValue(x).ToString() : "max. " + MaxCount.GetValue(x); return(string.Format(messageFormat, targetNumber, maxNumber)); } return(string.Format(messageFormat, targetNumber)); }
/// <summary> /// Submit a job to Splunk to be scheduled immediately. /// </summary> /// <param name="job">Job object containing details of the search job.</param> /// <returns>Returns the string containing the Splunk job identifier.</returns> public string SubmitJob(SplunkDataQuery job) { string path = "/services/search/jobs"; ServerRequest request = new ServerRequest(path, ServerRequest.HttpMethod.POST); request.Args.Add(new KeyValuePair <string, string>("search", job.Value)); request.Args.Add(new KeyValuePair <string, string>("earliest_time", string.Format("{0}.000+00:00", job.EarliestTime.ToUniversalTime().ToString("s")))); request.Args.Add(new KeyValuePair <string, string>("latest_time", string.Format("{0}.000+00:00", job.LatestTime.ToUniversalTime().ToString("s")))); request.Args.Add(new KeyValuePair <string, string>("max_count", MaxCount.ToString())); request.Args.Add(new KeyValuePair <string, string>("timeout", SearchJobTtl.ToString())); ServerResponse response = this.Send(request); var doc = new XmlDocument(); doc.LoadXml(response.Content); string sid; try { sid = doc.SelectSingleNode("/response/sid").InnerText; } catch (Exception) { throw new Exception(String.Format("Something went wrong while submitting the search to Splunk. The Splunk API returned:\n{0}", response.Content)); } return(sid); }
/// <summary> /// returns the string representation of the statistics. /// </summary> /// <returns></returns> public override string ToString() { lock (this) { System.Text.StringBuilder ret = new System.Text.StringBuilder(); ret.Append("Stats[Sch:" + ClassName + ", Cnt:" + Count.ToString() + ", "); ret.Append("Hi:" + HiCount.ToString() + ", "); ret.Append("MxS:" + MaxSize.ToString() + ", "); ret.Append("MxC:" + MaxCount.ToString() + ", "); ret.Append("Hit:" + HitCount.ToString() + ", "); ret.Append("Miss:" + MissCount.ToString() + "]"); return(ret.ToString()); } }
private void Update(EvaluationContext context) { if (MaxCount.DirtyFlag.IsDirty) { int maxCount = MaxCount.GetValue(context); ParticleSystem.Value.MaxCount = maxCount; ParticleSystem.Value.Init(); } if (MaxEmitRatePerFrame.DirtyFlag.IsDirty) { MaxEmitRatePerFrame.GetValue(context); } Log.Info("particle system setup updated"); }
public override int GetHashCode() { int hash = 1; if (Count != 0) { hash ^= Count.GetHashCode(); } if (MaxCount != 0) { hash ^= MaxCount.GetHashCode(); } hash ^= priceList_.GetHashCode(); return(hash); }
private void Update(EvaluationContext context) { if (MaxCount.DirtyFlag.IsDirty) { int maxCount = MaxCount.GetValue(context); Count.Value = maxCount; DeadListInitDispatch.Value = new Int3(maxCount / 64, 1, 1); UpdateDispatch.Value = new Int3(maxCount / 64, 1, 1); } if (MaxEmitRatePerFrame.DirtyFlag.IsDirty) { EmitDispatch.Value = new Int3(MaxEmitRatePerFrame.GetValue(context), 1, 1); } Log.Info("constants updated"); }
public override int GetHashCode() { int hash = 1; if (Index != 0) { hash ^= Index.GetHashCode(); } if (MaxCount != 0) { hash ^= MaxCount.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } hash ^= cards_.GetHashCode(); return(hash); }
public void ConcurrencyThrottle() { var maxCount = new MaxCount(); var node0 = new Vertex(() => Thread.Sleep(100)); var node10 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); var node11 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); var node12 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); var node13 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); var node14 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); var node15 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); var node16 = new Vertex(() => { maxCount.Inc(); Thread.Sleep(1000); maxCount.Dec(); }); node10.AddDependencies(node0); node11.AddDependencies(node0); node12.AddDependencies(node0); node13.AddDependencies(node0); node14.AddDependencies(node0); node15.AddDependencies(node0); node16.AddDependencies(node0); var executive = new GraphExecutive(new DirectedAcyclicGraph(node0), new ConcurrencyThrottle(2)); var resetEvent = new ManualResetEventSlim(); executive.OnGraphExecutionFinished += (sender, ergs) => resetEvent.Set(); executive.Execute(); resetEvent.Wait(); Assert.IsTrue(maxCount.Max < 3); }
public override Task Start(CancellationToken token) { Bind(BindingOptions.Value.EndPoint); _listener.Start(BindingOptions.Value.Backlog); Logger.LogInformation("Started, listening on {0}, protocol: {1}, max connections: {2}, backlog: {3}", _listener.LocalEndpoint, Protocol, MaxCount == 0 ? "unlimited" : MaxCount.ToString(), BindingOptions.Value.Backlog); Logger.LogInformation($"Shark server {Remote}"); token.Register(() => _listener.Stop()); return(StartAccept()); }
public async void UpdateSyncData() { var GetList = GetFileList(path, Id, pass, DrPath); /// Add Network Credentials // PTK async 2021-03-04 bool UseAsync = true; var lblini = ""; try { MaxCount = 2; // GetList.Count();// lblini = " of " + MaxCount.ToString() + " Completed!"; // _Progressbar = (System.Windows.Forms.ProgressBar)GetParentLbl(SenderParent).Controls.Find("progressBar1", true)[0]; _Progressbar.Visible = true; _Progressbar.Enabled = true; _Progressbar.Maximum = 100; _Progressbar.Minimum = 0; _Progressbar.Value = 0; _Progressbar.Step = 1; // _Progressbar.Text = "0" + lblini; _Progress = (GetParentLbl(SenderParent).Controls.Find("lblProgress", true)[0] as System.Windows.Forms.Label); _Progress.Visible = true; _Progress.Text = "0" + lblini; if (lblini == "") { // MessageBox.Show("empty"); UseAsync = false; } } catch (Exception ex) { // MessageBox.Show(ex.StackTrace); UseAsync = false; } // PTK async 2021-03-04 if (GetList != null) { int cc = 0; // _Progressbar.Value = 50;// Convert.ToInt32((Convert.ToInt32(cc) / MaxCount) * 100); _Progressbar.PerformStep(); _Progressbar.Update(); try { GetParentLbl(SenderParent).Refresh(); } catch (Exception ex) { // MessageBox.Show(ex.StackTrace); } foreach (string file in GetList) { if (cc == 2) { break; } cc++; if (UseAsync) { await Task.Run(() => { try { UpdateText(_Progressbar, cc.ToString() + lblini); UpdateText(_Progress, cc.ToString() + lblini); } catch { } }); } Download(file, path, Id, pass, DrPath); } MessageBox.Show("ダウンロードが終わりました", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); _Progressbar.Enabled = false; _Progressbar.Visible = false; _Progress.Text = ""; // System.Windows.Forms.Cursor.Current = Cursors.Default; } }
/// <summary> /// Opens the default label window /// </summary> /// <param name="position">The position where the window is going to be drawn</param> /// <param name="labels">Label array used to populate the list</param> /// <param name="selectedLabels">Selected labels</param> /// <param name="populateDefaultLabels">Should the default labels be included</param> /// <param name="allowMultipleSelection">Should the system allow more than 1 label selected</param> /// <param name="closeOnSelection">Should the window close on selection</param> /// <param name="allowCustom">Allow custom labels</param> /// <param name="maxCount">Max label count</param> /// <param name="sortAlphabetically">Should the labels be sorted</param> /// <param name="enableAutoCompletition">Should the window show auto completetion</param> public void OpenLabelWindow(Rect position, string[] labels, string[] selectedLabels, bool populateDefaultLabels = true, bool allowMultipleSelection = true, bool closeOnSelection = false, bool allowCustom = true, int maxCount = 15, bool sortAlphabetically = true, bool enableAutoCompletition = true) { if (labels == null) { labels = new string[] { } } ; if (selectedLabels == null) { selectedLabels = new string[] { } } ; this.allowMultipleSelection = allowMultipleSelection; this.allowCustom = allowCustom; //Cache the data required CacheData(labels, selectedLabels, populateDefaultLabels, closeOnSelection, maxCount, sortAlphabetically, enableAutoCompletition); //Create a reference of the window var popupListReference = Activator.CreateInstance(PopupList, new object[] { m_AssetLabels }); //Get the correct show method var showMethod = typeof(PopupWindow).GetMethods(BindingFlags.Static | BindingFlags.NonPublic).Where(x => x.Name.Equals("Show") && x.GetParameters().Length == 4).Single(); //Invoke the method with the correct arguments showMethod.Invoke(null, new object[] { position, popupListReference, null, 6 }); } void CacheData(string[] labels, string[] selectedLabels, bool populateDefaultLabels, bool closeOnSelection, int maxCount, bool sortAlphabetically, bool enableAutoCompletition) { //Create instance to the delegate Delegate action = Delegate.CreateDelegate(OnSelectCallback.FieldType, this, OnInternalSelectCallback); //Create instance of data to send to the popup window m_AssetLabels = Activator.CreateInstance(InputDataType); //Assign all the respective values, including the delegate callback CloseOnSelection.SetValue(m_AssetLabels, closeOnSelection); AllowCustom.SetValue(m_AssetLabels, true); OnSelectCallback.SetValue(m_AssetLabels, action); MaxCount.SetValue(m_AssetLabels, maxCount); SortAlphabetically.SetValue(m_AssetLabels, sortAlphabetically); EnableAutoCompletion.SetValue(m_AssetLabels, enableAutoCompletition); //Get all the labels available if (populateDefaultLabels) { allLabels = (Dictionary <string, float>) typeof(AssetDatabase).InvokeMember("GetAllLabels", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, null); } //Include any custom one sent on the array foreach (var tag in labels) { if (string.IsNullOrEmpty(tag)) { continue; } if (!allLabels.ContainsKey(tag)) { allLabels.Add(tag, 0); } } //Asing all the selected values foreach (var pair in allLabels) { var element = NewOrMatchingElement.Invoke(m_AssetLabels, new object[] { pair.Key }); if ((float)(FilterScore.GetValue(element, null)) < pair.Value) { FilterScore.SetValue(element, pair.Value, null); } Selected.SetValue(element, selectedLabels.Any(label => string.Equals(label, pair.Key, StringComparison.OrdinalIgnoreCase)), null); } } /// <summary> /// Function called by Unity when an element is selected /// </summary> /// <param name="data">Element data</param> void _OnInternalSelectCallback <T>(T data) { string selectedLabel = Text.GetValue(data, null).ToString(); if (!allowCustom && !allLabels.Keys.Any(x => x.ToLower().Equals(selectedLabel.ToLower()))) { return; } if (!allowMultipleSelection) { foreach (var pair in allLabels) { if (pair.Key.ToLower().Equals(selectedLabel.ToLower())) { continue; } var element = NewOrMatchingElement.Invoke(m_AssetLabels, new object[] { pair.Key }); Selected.SetValue(element, false, null); } } bool currentValue = (bool)(Selected.GetValue(data, null)); Selected.SetValue(data, !currentValue, null); if (OnSelect != null) { OnSelect.Invoke(selectedLabel, !currentValue); } } } }