Private cachePolicy As New CacheItemPolicy()
Private removedCount As Long = 0
- Public Sub New(ByVal memoryCacheCount As Integer)
+ Public Sub New(ByVal cacheMemoryLimit As Integer)
SyncLock Me.lockObject
'10Mb,80%
+ 'キャッシュチェック間隔はデフォルト値(2分毎)
Me.innerDictionary = New MemoryCache("imageCache",
New NameValueCollection() From
{
- {"CacheMemoryLimitMegabytes", "10"},
+ {"CacheMemoryLimitMegabytes", cacheMemoryLimit.ToString},
{"PhysicalMemoryLimitPercentage", "80"}
})
Me.waitStack = New Stack(Of KeyValuePair(Of String, Action(Of Image)))
Me.cachePolicy.RemovedCallback = AddressOf CacheRemoved
- Me.cachePolicy.SlidingExpiration = TimeSpan.FromMinutes(30)
+ Me.cachePolicy.SlidingExpiration = TimeSpan.FromMinutes(30) '30分参照されなかったら削除
End SyncLock
End Sub
Inherits ListViewItem
Private img As Image = Nothing
+ Public Event ImageDownloaded(ByVal sender As Object, ByVal e As EventArgs)
Public Sub New(ByVal items() As String, ByVal imageKey As String)
MyBase.New(items, imageKey)
Me.ListView.Created AndAlso
Not Me.ListView.IsDisposed Then Me.ListView.Invoke(Sub()
If Me.Index < Me.ListView.VirtualListSize Then Me.ListView.RedrawItems(Me.Index, Me.Index, False)
+ RaiseEvent ImageDownloaded(Me, EventArgs.Empty)
End Sub)
End Sub)
Private WithEvents TimerTimeline As New System.Timers.Timer
+ Private WithEvents displayItem As ImageListViewItem
+
'URL短縮のUndo用
Private Structure urlUndo
Public Before As String
End If
'アイコンリスト作成
- TIconDic = New ImageDictionary(5000)
+ TIconDic = New ImageDictionary(50)
tw.DetailIcon = TIconDic
Return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter
End Function
- Private Sub SetUserPicture()
- Thread.Sleep(1000) ' 要調整
- If Not String.IsNullOrEmpty(_curPost.ImageUrl) AndAlso TIconDic.ContainsKey(_curPost.ImageUrl) Then
- UserPicture.Image = TIconDic(_curPost.ImageUrl)
- End If
+ Private Sub DisplayItemImage_Downloaded(ByVal sender As Object, ByVal e As EventArgs) Handles displayItem.ImageDownloaded
+ If sender.Equals(displayItem) AndAlso displayItem.Image IsNot Nothing Then UserPicture.Image = displayItem.Image
End Sub
Private Overloads Sub DispSelectedPost()
End If
displaypost = _curPost
+ displayItem = DirectCast(_curList.Items(_curList.SelectedIndices(0)), ImageListViewItem)
+
Dim dTxt As String = createDetailHtml(If(_curPost.IsDeleted, "(DELETED)", _curPost.OriginalData))
If _curPost.IsDm Then
SourceLinkLabel.Tag = Nothing
UserPicture.Image = TIconDic(_curPost.ImageUrl)
Else
UserPicture.Image = Nothing
-
- Dim proc As New Thread(New Threading.ThreadStart(Sub()
- If Me.IsHandleCreated AndAlso Not Me.IsDisposed Then Invoke(New MethodInvoker(AddressOf SetUserPicture))
- End Sub))
- proc.Start()
End If
NameLabel.ForeColor = System.Drawing.SystemColors.ControlText