Content list thread-safe (#31)

This commit is contained in:
ksh 2021-08-15 00:35:49 +09:00 committed by GitHub
parent cbfa535d20
commit 62ae53fcec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 74 deletions

View file

@ -103,7 +103,7 @@ LANG=日本語
405=ふつう
406=わるい
407=グラフ
408=クライアントの接触がない場合のDC選択
408=基本DC選択
409=現在アドレス
410=グラフタイプ
411=線形

View file

@ -103,7 +103,7 @@ LANG=한국어(액토즈)
405=보통
406=나쁨
407=그래프 보기
408=클라이언트의 접속이 없을때 사용할 DC 선택
408=기본으로 테스트할 DC
409=연결된 IP주소
410=그래프 모양
411=선형

View file

@ -103,7 +103,7 @@ LANG=한국어
405=보통
406=나쁨
407=그래프 보기
408=클라이언트의 접속이 없을때 사용할 DC 선택
408=기본으로 테스트할 DC
409=현재 연결 IP
410=그래프 모양
411=선형

View file

@ -12,7 +12,7 @@ namespace DutyContent
{
class DcConfig
{
public static int PluginTag => 15;
public static int PluginTag => 16;
public static Version PluginVersion => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
public static bool PluginEnable { get; set; }

View file

@ -4,6 +4,6 @@
* Network analyzer codes from https://github.com/Noisyfox/ACT.FFXIVPing
## New test version
[Download Release 15 ](https://github.com/kshman/DutyContent/releases/tag/15)
[Download Release 16 ](https://github.com/kshman/DutyContent/releases/tag/16)
Please try & test new pre-release version!!! 🤗

View file

@ -525,29 +525,32 @@ namespace DutyContent.Tab
if (withlog)
WriteLog(Color.Black, key, 10001, fate.Name);
lock (_lock_contents)
WorkerAct.Invoker(() =>
{
var sc = code.ToString();
var i = UnsafeFindContent(sc, out int nth);
if (i == null && progress >= 0)
lock (_lock_contents)
{
var li = new ThirdParty.EXListViewItem(sc);
var si = new ThirdParty.EXImageListViewSubItem(_ilCategory.Images[subs], "");
var sc = code.ToString();
var i = UnsafeFindContent(sc, out int nth);
li.SubItems.Add(si);
li.SubItems.Add(progress.ToString());
li.SubItems.Add(fate.Name);
lstContents.Items.Add(li);
if (i == null && progress >= 0)
{
var li = new ThirdParty.EXListViewItem(sc);
var si = new ThirdParty.EXImageListViewSubItem(_ilCategory.Images[subs], "");
li.SubItems.Add(si);
li.SubItems.Add(progress.ToString());
li.SubItems.Add(fate.Name);
lstContents.Items.Add(li);
}
else
{
if (progress >= 0)
i.SubItems[2].Text = progress.ToString();
else if (nth >= 0)
lstContents.Items.RemoveAt(nth);
}
}
else
{
if (progress >= 0)
i.SubItems[2].Text = progress.ToString();
else if (nth >= 0)
lstContents.Items.RemoveAt(nth);
}
}
});
}
//
@ -556,51 +559,57 @@ namespace DutyContent.Tab
if (withlog)
WriteLog(Color.Black, 25, 10001, fate.Name);
lock (_lock_contents)
WorkerAct.Invoker(() =>
{
var sc = code.ToString();
var i = UnsafeFindContent(sc, out int nth);
if (i == null && progress != null)
lock (_lock_contents)
{
var li = new ThirdParty.EXListViewItem(sc);
var si = new ThirdParty.EXImageListViewSubItem(_ilCategory.Images[5], "");
var sc = code.ToString();
var i = UnsafeFindContent(sc, out int nth);
li.SubItems.Add(si);
li.SubItems.Add(progress.ToString());
li.SubItems.Add(fate.Name);
lstContents.Items.Add(li);
}
else
{
if (progress == null)
lstContents.Items.RemoveAt(nth);
if (i == null && progress != null)
{
var li = new ThirdParty.EXListViewItem(sc);
var si = new ThirdParty.EXImageListViewSubItem(_ilCategory.Images[5], "");
li.SubItems.Add(si);
li.SubItems.Add(progress.ToString());
li.SubItems.Add(fate.Name);
lstContents.Items.Add(li);
}
else
i.SubItems[2].Text = progress;
{
if (progress == null)
lstContents.Items.RemoveAt(nth);
else
i.SubItems[2].Text = progress;
}
}
}
});
}
//
private void UpdateTraceInstance(string insname, int count, int imageindex)
{
lock (_lock_contents)
WorkerAct.Invoker(() =>
{
if (lstContents.Items.Count > 0)
lock (_lock_contents)
{
//lstContents.BeginUpdate();
if (lstContents.Items.Count > 0)
{
//lstContents.BeginUpdate();
var li = lstContents.Items[0];
var li = lstContents.Items[0];
var si = li.SubItems[1] as ThirdParty.EXImageListViewSubItem;
si.MyImage = _ilCategory.Images[imageindex];
var si = li.SubItems[1] as ThirdParty.EXImageListViewSubItem;
si.MyImage = _ilCategory.Images[imageindex];
li.SubItems[2].Text = count == 0 ? string.Empty : count.ToString();
li.SubItems[3].Text = insname;
li.SubItems[2].Text = count == 0 ? string.Empty : count.ToString();
li.SubItems[3].Text = insname;
//lstContents.EndUpdate();
//lstContents.EndUpdate();
}
}
}
});
}
//
@ -1774,15 +1783,18 @@ namespace DutyContent.Tab
private void ResetContents()
{
lock (_lock_contents)
WorkerAct.Invoker(() =>
{
lstContents.BeginUpdate();
lock (_lock_contents)
{
lstContents.BeginUpdate();
for (var i = lstContents.Items.Count - 1; i > 0; i--)
lstContents.Items.RemoveAt(1);
for (var i = lstContents.Items.Count - 1; i > 0; i--)
lstContents.Items.RemoveAt(1);
lstContents.EndUpdate();
}
lstContents.EndUpdate();
}
});
}
private ListViewItem UnsafeFindContent(string code, out int nth)
@ -1804,21 +1816,5 @@ namespace DutyContent.Tab
return null;
}
private void RemoveContent(string code)
{
if (lstContents.Items.Count <= 1)
return;
for (var i = 1; i < lstContents.Items.Count; i++)
{
var v = lstContents.Items[i];
if (v.Text.Equals(code))
{
lstContents.Items.RemoveAt(i);
break;
}
}
}
}
}