|
203 | 203 | ''' </summary> |
204 | 204 | Public DlClientListMojangLoader As New LoaderTask(Of String, DlClientListResult)("DlClientList Mojang", AddressOf DlClientListMojangMain) |
205 | 205 | Private IsNewClientVersionHinted As Boolean = False |
| 206 | + Private ReadOnly HintLock As New Object() ' 线程安全锁 |
206 | 207 | Private Sub DlClientListMojangMain(Loader As LoaderTask(Of String, DlClientListResult)) |
207 | 208 | Dim StartTime As Long = GetTimeTick() |
208 | 209 | Dim Json As JObject = GetJson(NetRequestByClientRetry("https://launchermeta.mojang.com/mc/game/version_manifest.json", RequireJson:=True)) |
|
222 | 223 | '解析更新提示(Release) |
223 | 224 | Dim Version As String = Json("latest")("release") |
224 | 225 | If Setup.Get("ToolUpdateRelease") AndAlso Not Setup.Get("ToolUpdateReleaseLast") = "" AndAlso Version IsNot Nothing AndAlso Not Setup.Get("ToolUpdateReleaseLast") = Version Then |
225 | | - McDownloadClientUpdateHint(Version, Json) |
226 | | - IsNewClientVersionHinted = True |
| 226 | + SyncLock HintLock |
| 227 | + If Not IsNewClientVersionHinted Then ' 在锁内再次检查 |
| 228 | + McDownloadClientUpdateHint(Version, Json) |
| 229 | + IsNewClientVersionHinted = True |
| 230 | + End If |
| 231 | + End SyncLock |
227 | 232 | End If |
228 | 233 | McVersionHighest = Version.Split(".")(1) |
229 | 234 | Setup.Set("ToolUpdateReleaseLast", Version) |
230 | 235 | '解析更新提示(Snapshot) |
231 | 236 | Version = Json("latest")("snapshot") |
232 | | - If Setup.Get("ToolUpdateSnapshot") AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = "" AndAlso Version IsNot Nothing AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = Version AndAlso Not IsNewClientVersionHinted Then |
233 | | - McDownloadClientUpdateHint(Version, Json) |
| 237 | + If Setup.Get("ToolUpdateSnapshot") AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = "" AndAlso Version IsNot Nothing AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = Version Then |
| 238 | + SyncLock HintLock |
| 239 | + If Not IsNewClientVersionHinted Then ' 在锁内再次检查 |
| 240 | + McDownloadClientUpdateHint(Version, Json) |
| 241 | + IsNewClientVersionHinted = True |
| 242 | + End If |
| 243 | + End SyncLock |
234 | 244 | End If |
235 | 245 | Setup.Set("ToolUpdateSnapshotLast", If(Version, "Nothing")) |
236 | 246 | Catch ex As Exception |
|
0 commit comments