Stop
How do I use Stop
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: frmThi.cs
Copy
225 private void timer1_Tick(object sender, EventArgs e)
226 {
227 p--;
228 lbtime.Text =p.ToString() +" phut";
229 if (p==0)
230 {
231 timer1.Stop();
232 MessageBox.Show("Da het gio lam bai");
233 }
234 }
File name: frmThiThat.cs
Copy
261 private void btketthuc_Click(object sender, EventArgs e)
262 {
263 if (MessageBox.Show("Bạn có chắc chắn kết thúc không ?" , "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
264 {
265 this.Hide();
266 try
267 {
268 timer1.Stop();
269 btketthuc.Enabled = false;
270
271 GhiLaiDapAnTS();
272 SoCauDung = 0;
273 for (int i = 0; i < SoCauHoi; i++)
274 {
275 if (BangDeThi.Rows[i][6].ToString().ToUpper() == BangDeThi.Rows[i][7].ToString().ToUpper())
276 SoCauDung++;
277
278 }
279
280 diem = SoCauDung * 2;
281 MessageBox.Show("Đúng " + SoCauDung.ToString() + " câu " + " Bạn được " + diem.ToString() + " điểm ");
282 this.Close();
283 string ten = lbhoten.Text;
284 string mats = lbmathisinh.Text;
285 string diem1 = diem.ToString();
286 string socaudung = SoCauDung.ToString();
287 frmKetQua ketqua = new frmKetQua(ten,mats,diem1,socaudung);
288 ketqua.ShowDialog();
289 //them form ket qua tai day
290
291 }
292 catch (Exception ex)
293 { MessageBox.Show(ex.Message); }
294 }
295 else
296 { return; }
297 }
File name: frmThiThat.cs
Copy
301 private void timer1_Tick_1(object sender, EventArgs e)
302 {
303 timer1.Interval = 1000;
304
305 s--;
306 th--;
307 if (th == 0)
308 {
309 timer1.Stop();
310 MessageBox.Show("Hết giờ làm bài!", "Thong bao");
311 checkBox1.Checked = false;
312 checkBox2.Checked = false;
313 checkBox3.Checked = false;
314 checkBox4.Checked = false;
315
316 GhiLaiDapAnTS();
317 SoCauDung = 0;
318 for (int i = 0; i < SoCauHoi; i++)
319 {
320 if (BangDeThi.Rows[i][6].ToString().ToUpper() == BangDeThi.Rows[i][7].ToString().ToUpper())
321 SoCauDung++;
322 }
323 int diem;
324 diem = SoCauDung * 2;
325 MessageBox.Show("Đúng " + SoCauDung.ToString()+" câu " + " Bạn được " + diem.ToString() + " điểm ");
326 this.Close();
327
328 }
329 if (s == 0)
330 {
331 p--;
332 if (p == 0)
333 {
334 s = 60;
335 th = s;
336 }
337 s = 60;
338 }
339
340 lblHour.Text = h.ToString() + " : " + p.ToString() + " : " + s.ToString();
341
342 }
File name: NamePickGui.cs
Copy
38 public void OnGUI()
39 {
40 // Enter-Key handling:
41 if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
42 {
43 if (!string.IsNullOrEmpty(this.InputLine))
44 {
45 this.StartChat();
46 return;
47 }
48 }
49
50
51 GUI.skin.label.wordWrap = true;
52 GUILayout.BeginArea(guiCenteredRect);
53
54
55 if (this.chatComponent != null && string.IsNullOrEmpty(this.chatComponent.ChatAppId))
56 {
57 GUILayout.Label("To continue, configure your Chat AppId.\nIt's listed in the Chat Dashboard (online).\nStop play-mode and edit:\nScripts/ChatGUI in the Hierarchy.");
58 if (GUILayout.Button("Open Chat Dashboard"))
59 {
60 Application.OpenURL("https://www.exitgames.com/en/Chat/Dashboard");
61 }
62 GUILayout.EndArea();
63 return;
64 }
65
66 GUILayout.Label(this.helpText);
67
68 GUILayout.BeginHorizontal();
69 GUI.SetNextControlName("NameInput");
70 this.InputLine = GUILayout.TextField(this.InputLine);
71 if (GUILayout.Button("Connect", GUILayout.ExpandWidth(false)))
72 {
73 this.StartChat();
74 }
75 GUILayout.EndHorizontal();
76
77 GUILayout.EndArea();
78
79
80 GUI.FocusControl("NameInput");
81 }
File name: PhotonHandler.cs
Copy
52 protected void OnApplicationQuit()
53 {
54 PhotonHandler.AppQuits = true;
55 PhotonHandler.StopFallbackSendAckThread();
56 PhotonNetwork.Disconnect();
57 }
File name: PhotonHandler.cs
Copy
139 public static void StopFallbackSendAckThread()
140 {
141 sendThreadShouldRun = false;
142 }
File name: PhotonNetwork.cs
Copy
1025 /// Connect(serverAddress, 1036 public static void SwitchToProtocol(ConnectionProtocol cp)
1037 {
1038 if (networkingPeer.UsedProtocol == cp)
1039 {
1040 return;
1041 }
1042 try
1043 {
1044 networkingPeer.Disconnect();
1045 networkingPeer.StopThread();
1046 }
1047 catch
1048 {
1049
1050 }
1051
1052 // set up a new NetworkingPeer
1053 NetworkingPeer newPeer = new NetworkingPeer(photonMono, String.Empty, cp);
1054 newPeer.mAppVersion = networkingPeer.mAppVersion;
1055 newPeer.CustomAuthenticationValues = networkingPeer.CustomAuthenticationValues;
1056 newPeer.PlayerName= networkingPeer.PlayerName;
1057 newPeer.mLocalActor = networkingPeer.mLocalActor;
1058 newPeer.DebugOut = networkingPeer.DebugOut;
1059 newPeer.CrcEnabled = networkingPeer.CrcEnabled;
1060 newPeer.lobby = networkingPeer.lobby;
1061 newPeer.LimitOfUnreliableCommands = networkingPeer.LimitOfUnreliableCommands;
1062 newPeer.SentCountAllowance = networkingPeer.SentCountAllowance;
1063 newPeer.TrafficStatsEnabled = networkingPeer.TrafficStatsEnabled;
1064
1065 networkingPeer = newPeer;
1066 Debug.LogWarning("Protocol switched to: " + cp + ".");
1067 }
File name: PhotonStatsGui.cs
Copy
77 public void TrafficStatsWindow(int windowID)
78 {
79 bool statsToLog = false;
80 TrafficStatsGameLevel gls = PhotonNetwork.networkingPeer.TrafficStatsGameLevel;
81 long elapsedMs = PhotonNetwork.networkingPeer.TrafficStatsElapsedMs / 1000;
82 if (elapsedMs == 0)
83 {
84 elapsedMs = 1;
85 }
86
87 GUILayout.BeginHorizontal();
88 this.buttonsOn = GUILayout.Toggle(this.buttonsOn, "buttons");
89 this.healthStatsVisible = GUILayout.Toggle(this.healthStatsVisible, "health");
90 this.trafficStatsOn = GUILayout.Toggle(this.trafficStatsOn, "traffic");
91 GUILayout.EndHorizontal();
92
93 string total = string.Format("Out|In|Sum:\t{0,4} | {1,4} | {2,4}", gls.TotalOutgoingMessageCount, gls.TotalIncomingMessageCount, gls.TotalMessageCount);
94 string elapsedTime = string.Format("{0}sec average:", elapsedMs);
95 string average = string.Format("Out|In|Sum:\t{0,4} | {1,4} | {2,4}", gls.TotalOutgoingMessageCount / elapsedMs, gls.TotalIncomingMessageCount / elapsedMs, gls.TotalMessageCount / elapsedMs);
96 GUILayout.Label(total);
97 GUILayout.Label(elapsedTime);
98 GUILayout.Label(average);
99
100 if (this.buttonsOn)
101 {
102 GUILayout.BeginHorizontal();
103 this.statsOn = GUILayout.Toggle(this.statsOn, "stats on");
104 if (GUILayout.Button("Reset"))
105 {
106 PhotonNetwork.networkingPeer.TrafficStatsReset();
107 PhotonNetwork.networkingPeer.TrafficStatsEnabled = true;
108 }
109 statsToLog = GUILayout.Button("To Log");
110 GUILayout.EndHorizontal();
111 }
112
113 string trafficStatsIn = string.Empty;
114 string trafficStatsOut = string.Empty;
115 if (this.trafficStatsOn)
116 {
117 trafficStatsIn = "Incoming: " + PhotonNetwork.networkingPeer.TrafficStatsIncoming.ToString();
118 trafficStatsOut = "Outgoing: " + PhotonNetwork.networkingPeer.TrafficStatsOutgoing.ToString();
119 GUILayout.Label(trafficStatsIn);
120 GUILayout.Label(trafficStatsOut);
121 }
122
123 string healthStats = string.Empty;
124 if (this.healthStatsVisible)
125 {
126 healthStats = string.Format(
127 "ping: {6}[+/-{7}]ms\nlongest delta between\nsend: {0,4}ms disp: {1,4}ms\nlongest time for:\nev({3}):{2,3}ms op({5}):{4,3}ms",
128 gls.LongestDeltaBetweenSending,
129 gls.LongestDeltaBetweenDispatching,
130 gls.LongestEventCallback,
131 gls.LongestEventCallbackCode,
132 gls.LongestOpResponseCallback,
133 gls.LongestOpResponseCallbackOpCode,
134 PhotonNetwork.networkingPeer.RoundTripTime,
135 PhotonNetwork.networkingPeer.RoundTripTimeVariance);
136 GUILayout.Label(healthStats);
137 }
138
139 if (statsToLog)
140 {
141 string complete = string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}", total, elapsedTime, average, trafficStatsIn, trafficStatsOut, healthStats);
142 Debug.Log(complete);
143 }
144
145 // if anything was clicked, the height of this window is likely changed. reduce it to be layouted again next frame
146 if (GUI.changed)
147 {
148 this.statsRect.height = 100;
149 }
150
151 GUI.DragWindow();
152 }
File name: PhotonView.cs
Copy
290 protected internal void OnApplicationQuit()
291 {
292 destroyedByPhotonNetworkOrQuit = true; // on stop-playing its ok Destroy is being called directly (not by PN.Destroy())
293 }
File name: PingCloudRegions.cs
Copy
118 public IEnumerator PingSocket(Region region)
119 {
120 region.Ping = Attempts*MaxMilliseconsPerPing;
121
122 this.PingsRunning++; // TODO: Add try-catch to make sure the PingsRunning are reduced at the end and that the lib does not crash the app
123 PhotonPing ping;
124 //Debug.Log("PhotonHandler.PingImplementation " + PhotonHandler.PingImplementation);
125 if (PhotonHandler.PingImplementation == typeof(PingNativeDynamic))
126 {
127 Debug.Log("Using constructor for new PingNativeDynamic()"); // it seems on android, the Activator can't find the default Constructor
128 ping = new PingNativeDynamic();
129 }
130 else
131 {
132 ping = (PhotonPing)Activator.CreateInstance(PhotonHandler.PingImplementation);
133 }
134
135 //Debug.Log("Ping is: " + ping + " type " + ping.GetType());
136
137 float rttSum = 0.0f;
138 int replyCount = 0;
139
140
141 // PhotonPing.StartPing() requires a plain IP address without port (on all but Windows 8 platforms).
142 // So: remove port and do the DNS-resolving if needed
143 string cleanIpOfRegion = region.HostAndPort;
144 int indexOfColon = cleanIpOfRegion.LastIndexOf(':');
145 if (indexOfColon > 1)
146 {
147 cleanIpOfRegion = cleanIpOfRegion.Substring(0, indexOfColon);
148 }
149 cleanIpOfRegion = ResolveHost(cleanIpOfRegion);
150 //Debug.Log("Resolved and port-less IP is: " + cleanIpOfRegion);
151
152
153 for (int i = 0; i < Attempts; i++)
154 {
155 bool overtime = false;
156 Stopwatch sw = new Stopwatch();
157 sw.Start();
158
159 try
160 {
161 ping.StartPing(cleanIpOfRegion);
162 }
163 catch (Exception e)
164 {
165 Debug.Log("catched: " + e);
166 this.PingsRunning--;
167 break;
168 }
169
170
171 while (!ping.Done())
172 {
173 if (sw.ElapsedMilliseconds >= MaxMilliseconsPerPing)
174 {
175 overtime = true;
176 break;
177 }
178 yield return 0; // keep this loop tight, to avoid adding local lag to rtt.
179 }
180 int rtt = (int)sw.ElapsedMilliseconds;
181
182
183 if (IgnoreInitialAttempt && i == 0)
184 {
185 // do nothing.
186 }
187 else if (ping.Successful && !overtime)
188 {
189 rttSum += rtt;
190 replyCount++;
191 region.Ping = (int)((rttSum) / replyCount);
192 //Debug.Log("region " + region.Code + " RTT " + region.Ping + " success: " + ping.Successful + " over: " + overtime);
193 }
194
195 yield return new WaitForSeconds(0.1f);
196 }
197
198 this.PingsRunning--;
199
200 //Debug.Log("this.PingsRunning: " + this.PingsRunning + " this debug: " + ping.DebugString);
201 yield return null;
202 }
Download file with original file name:Stop
Stop 117 lượt xem
Gõ tìm kiếm nhanh...