• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

開発に使用するリポジトリ


Commit MetaInfo

Revisión4f2d60256d02255bf58d797b7eea9a5f86a244a8 (tree)
Tiempo2013-01-19 20:21:04
AutorKimura Youichi <kim.upsilon@bucy...>
CommiterKimura Youichi

Log Message

img.azyobuzi.net 正規表現の更新にSystem.Therading.Timerを使用

Cambiar Resumen

Diferencia incremental

--- a/OpenTween/Thumbnail/Services/ImgAzyobuziNet.cs
+++ b/OpenTween/Thumbnail/Services/ImgAzyobuziNet.cs
@@ -22,25 +22,22 @@
2222 using System;
2323 using System.Collections.Generic;
2424 using System.Linq;
25-using System.Text;
2625 using System.Net;
2726 using System.Runtime.Serialization.Json;
2827 using System.Xml;
2928 using System.Xml.Linq;
30-using System.Xml.XPath;
3129 using System.Text.RegularExpressions;
32-using System.Threading.Tasks;
3330 using System.Threading;
34-using System.Windows.Forms;
3531
3632 namespace OpenTween.Thumbnail.Services
3733 {
38- class ImgAzyobuziNet : IThumbnailService
34+ class ImgAzyobuziNet : IThumbnailService, IDisposable
3935 {
4036 protected string[] ApiHosts = { "http://img.azyobuzi.net/api/", "http://img.opentween.org/api/" };
4137
4238 protected string ApiBase;
4339 protected IEnumerable<Regex> UrlRegex = new Regex[] {};
40+ protected Timer UpdateTimer;
4441
4542 private object LockObj = new object();
4643
@@ -48,20 +45,33 @@ namespace OpenTween.Thumbnail.Services
4845 {
4946 this.LoadRegex();
5047
51- if (autoupdate)
52- this.StartAutoUpdate();
48+ this.UpdateTimer = new Timer(_ => this.LoadRegex());
49+ this.AutoUpdate = autoupdate;
5350 }
5451
55- public void StartAutoUpdate()
52+ public bool AutoUpdate
5653 {
57- Task.Factory.StartNew(() =>
54+ get { return this._AutoUpdate; }
55+ set
5856 {
59- for (;;)
60- {
61- Thread.Sleep(30 * 60 * 1000); // 30分おきに更新
62- this.LoadRegex();
63- }
64- }, TaskCreationOptions.LongRunning);
57+ if (value)
58+ this.StartAutoUpdate();
59+ else
60+ this.StopAutoUpdate();
61+
62+ this._AutoUpdate = value;
63+ }
64+ }
65+ private bool _AutoUpdate = false;
66+
67+ protected void StartAutoUpdate()
68+ {
69+ this.UpdateTimer.Change(0, 30 * 60 * 1000); ; // 30分おきに更新
70+ }
71+
72+ protected void StopAutoUpdate()
73+ {
74+ this.UpdateTimer.Change(Timeout.Infinite, Timeout.Infinite);
6575 }
6676
6777 public void LoadRegex()
@@ -135,5 +145,10 @@ namespace OpenTween.Thumbnail.Services
135145
136146 return null;
137147 }
148+
149+ public virtual void Dispose()
150+ {
151+ this.UpdateTimer.Dispose();
152+ }
138153 }
139154 }