Добавлены мьютексы
This commit is contained in:
parent
960e855301
commit
8f82374370
@ -11,6 +11,7 @@ namespace AnchorsTest
|
||||
{
|
||||
internal class TagsTimerController
|
||||
{
|
||||
public static Mutex _Mutex = new Mutex();
|
||||
List<string> listContent;
|
||||
|
||||
private System.Threading.Timer _timer;
|
||||
@ -72,7 +73,9 @@ namespace AnchorsTest
|
||||
{
|
||||
//responce.Content.ReadAsStringAsync();
|
||||
string responceContentString = await responce.Content.ReadAsStringAsync();
|
||||
_Mutex.WaitOne();
|
||||
listContent.Add(responceContentString);
|
||||
_Mutex.ReleaseMutex();
|
||||
Debug.WriteLine(responceContentString);
|
||||
++Configuration.Get.counterGet;
|
||||
}
|
||||
@ -80,18 +83,27 @@ namespace AnchorsTest
|
||||
|
||||
public string SerializeObject()
|
||||
{
|
||||
List<string> jsonStrings = listContent;
|
||||
|
||||
// Deserialize each string into an object
|
||||
List<object> objects = new List<object>();
|
||||
foreach (var jsonString in jsonStrings)
|
||||
_Mutex.WaitOne();
|
||||
string serializedJson = "";
|
||||
try
|
||||
{
|
||||
objects.Add(JsonConvert.DeserializeObject(jsonString));
|
||||
}
|
||||
List<string> jsonStrings = listContent;
|
||||
|
||||
// Serialize the list of objects back to JSON
|
||||
string serializedJson = JsonConvert.SerializeObject(objects, Formatting.Indented);
|
||||
Console.WriteLine(serializedJson);
|
||||
// Deserialize each string into an object
|
||||
List<object> objects = new List<object>();
|
||||
foreach (var jsonString in jsonStrings)
|
||||
{
|
||||
objects.Add(JsonConvert.DeserializeObject(jsonString));
|
||||
}
|
||||
|
||||
// Serialize the list of objects back to JSON
|
||||
serializedJson = JsonConvert.SerializeObject(objects, Formatting.Indented);
|
||||
Console.WriteLine(serializedJson);
|
||||
}catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
_Mutex.ReleaseMutex();
|
||||
return serializedJson;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user