From fd1b481ad417c846c66433dff8de4b2a938d4a78 Mon Sep 17 00:00:00 2001 From: kiri_feather Date: Wed, 8 Sep 2010 04:08:58 +0000 Subject: [PATCH] =?utf8?q?CachedImage=E3=82=92=E3=82=B9=E3=83=AC=E3=83=83?= =?utf8?q?=E3=83=89=E3=82=BB=E3=83=BC=E3=83=95=E3=81=AB=E3=80=82=20Setting?= =?utf8?q?.vb=E3=81=A7Invoke=E3=81=99=E3=82=8B=E6=99=82=E3=80=81=E3=82=A6?= =?utf8?q?=E3=82=A3=E3=83=B3=E3=83=89=E3=82=A6=E3=83=8F=E3=83=B3=E3=83=89?= =?utf8?q?=E3=83=AB=E4=BD=9C=E6=88=90=E6=B8=88=E3=81=BF=E3=81=8B=E3=81=AE?= =?utf8?q?=E5=88=A4=E5=AE=9A=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@830 e39ad16e-3079-482e-bb30-4b4d378143b6 --- Tween/ImageCacheDictionary.vb | 36 +++++++++++++++++++----------------- Tween/Setting.vb | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Tween/ImageCacheDictionary.vb b/Tween/ImageCacheDictionary.vb index 4a0839a6..45019fa8 100644 --- a/Tween/ImageCacheDictionary.vb +++ b/Tween/ImageCacheDictionary.vb @@ -6,7 +6,7 @@ Public Class ImageCacheDictionary Dim memoryCacheCount As Integer Private innerDictionary As Dictionary(Of String, CachedImage) - Private sortedKeyList As List(Of String) + Private sortedKeyList As List(Of String) '古いもの順 Public Sub New(ByVal memoryCacheCount As Integer) Me.innerDictionary = New Dictionary(Of String, CachedImage)(memoryCacheCount + 1) @@ -144,33 +144,35 @@ Public Class ImageCacheDictionary Private img As Image = Nothing Private tmpFilePath As String = Nothing + Private Shared lockObject As New Object Public Sub New(ByVal img As Image) Me.img = img End Sub - Public Property Image As Image + Public ReadOnly Property Image As Image Get - If Me.img Is Nothing Then - Me.img = Image.FromFile(Me.tmpFilePath) - End If + SyncLock lockObject + If Me.img Is Nothing Then + Me.img = Image.FromFile(Me.tmpFilePath) + End If - Return Me.img + Return Me.img + End SyncLock End Get - Set(ByVal value As Image) - - End Set End Property Public Sub Chache() - If Me.tmpFilePath Is Nothing Then - Me.tmpFilePath = Path.GetTempFileName() - Me.img.Save(Me.tmpFilePath) - End If - If Me.img IsNot Nothing Then - Me.img.Dispose() - Me.img = Nothing - End If + SyncLock lockObject + If Me.tmpFilePath Is Nothing Then + Me.tmpFilePath = Path.GetTempFileName() + Me.img.Save(Me.tmpFilePath) + End If + If Me.img IsNot Nothing Then + Me.img.Dispose() + Me.img = Nothing + End If + End SyncLock End Sub Public Sub Dispose() Implements IDisposable.Dispose diff --git a/Tween/Setting.vb b/Tween/Setting.vb index a79fc1a5..d26dbabe 100644 --- a/Tween/Setting.vb +++ b/Tween/Setting.vb @@ -1854,7 +1854,7 @@ Public Class Setting info.UsingCount = UsingApi Dim proc As New Action(Of ApiInfo)(Sub(infoCount) tw.GetInfoApi(infoCount) '取得エラー時はinfoCountは初期状態(値:-1) - Me.Invoke(New Action(Of ApiInfo)(AddressOf DisplayApiMaxCount), infoCount) + If Me.IsHandleCreated Then Me.Invoke(New Action(Of ApiInfo)(AddressOf DisplayApiMaxCount), infoCount) End Sub) proc.BeginInvoke(info, Nothing, Nothing) Else -- 2.11.0