diff --git a/Data_Manager2/Classes/ConnectionHandler.cs b/Data_Manager2/Classes/ConnectionHandler.cs index 1333b191f..7845f26c2 100644 --- a/Data_Manager2/Classes/ConnectionHandler.cs +++ b/Data_Manager2/Classes/ConnectionHandler.cs @@ -180,7 +180,7 @@ private void onClientDisconneting(XMPPClient client) private void onClientConnected(XMPPClient client) { - Task.Factory.StartNew(async () => + Task.Run(async () => { await client.requestRoosterAsync(); await client.requestBookmarksAsync(); @@ -381,7 +381,7 @@ private void C_NewChatMessage(XMPPClient client, XMPP_API.Classes.Network.Events } // ToDo re-implement show toast message - /*Task.Factory.StartNew(() => + /*Task.Run(() => { if (!msg.getToasted()) { diff --git a/Data_Manager2/Classes/DBManager/DiscoDBManager.cs b/Data_Manager2/Classes/DBManager/DiscoDBManager.cs index 6fa4eda21..f2f317f9b 100644 --- a/Data_Manager2/Classes/DBManager/DiscoDBManager.cs +++ b/Data_Manager2/Classes/DBManager/DiscoDBManager.cs @@ -143,7 +143,7 @@ private async void INSTANCE_ClientConnected(ConnectionHandler handler, Data_Mana private void CLIENT_NewDiscoResponseMessage(XMPPClient client, XMPP_API.Classes.Network.Events.NewDiscoResponseMessageEventArgs args) { - Task.Factory.StartNew(async () => + Task.Run(async () => { string from = args.DISCO.getFrom(); // Only store direct server results: diff --git a/Data_Manager2/Classes/DBManager/ImageDBManager.cs b/Data_Manager2/Classes/DBManager/ImageDBManager.cs index e0c2cb635..5f6276359 100644 --- a/Data_Manager2/Classes/DBManager/ImageDBManager.cs +++ b/Data_Manager2/Classes/DBManager/ImageDBManager.cs @@ -140,7 +140,7 @@ private void contiuneAllDownloads() List list = dB.Query(true, "SELECT * FROM " + DBTableConsts.IMAGE_TABLE + " WHERE state = 0 OR state = 1;"); foreach (ImageTable img in list) { - Task.Factory.StartNew(async () => + Task.Run(async () => { // Reset image progress: img.progress = 0; @@ -205,7 +205,7 @@ public ImageTable retryImageDownload(ChatMessageTable msg) img.path = null; } - Task.Factory.StartNew(async () => + Task.Run(async () => { update(img); await downloadImageAsync(img, msg.message); @@ -238,7 +238,7 @@ public void downloadImage(ChatMessageTable msg) { if (msg.isImage) { - Task.Factory.StartNew(async () => + Task.Run(async () => { ImageTable img = new ImageTable() { diff --git a/Data_Manager2/Classes/MUCHandler.cs b/Data_Manager2/Classes/MUCHandler.cs index 3e50d8136..45cb5f97a 100644 --- a/Data_Manager2/Classes/MUCHandler.cs +++ b/Data_Manager2/Classes/MUCHandler.cs @@ -103,7 +103,7 @@ public Task updateBookmarks(XMPPClient client, ConferenceItem cI) #region --Misc Methods (Private)-- private void enterAllMUCs(XMPPClient client) { - Task.Factory.StartNew(async () => { + Task.Run(async () => { foreach (ChatTable muc in ChatDBManager.INSTANCE.getAllMUCs(client.getXMPPAccount().getIdAndDomain())) { MUCChatInfoTable info = MUCDBManager.INSTANCE.getMUCInfo(muc.id); diff --git a/Logging/Logger.cs b/Logging/Logger.cs index f363ac16b..d2d5d4152 100644 --- a/Logging/Logger.cs +++ b/Logging/Logger.cs @@ -178,7 +178,7 @@ public static async Task exportLogs() { return; } - await Task.Factory.StartNew(async () => + await Task.Run(async () => { try { diff --git a/Push_App_Server/Classes/PushManager.cs b/Push_App_Server/Classes/PushManager.cs index 606c417f4..0ee97b6c6 100644 --- a/Push_App_Server/Classes/PushManager.cs +++ b/Push_App_Server/Classes/PushManager.cs @@ -50,7 +50,7 @@ public static void init() #region --Events-- private static void INSTANCE_ClientConnected(ConnectionHandler handler, Data_Manager.Classes.Events.ClientConnectedEventArgs args) { - Task.Factory.StartNew(async () => + Task.Run(async () => { DataWriter dW = new DataWriter(args.CLIENT); await dW.connectAndSendAsync(); diff --git a/UWP XMPP Client/App.xaml.cs b/UWP XMPP Client/App.xaml.cs index 832c442b5..669a8a832 100644 --- a/UWP XMPP Client/App.xaml.cs +++ b/UWP XMPP Client/App.xaml.cs @@ -70,7 +70,7 @@ private void OnSuspending(object sender, SuspendingEventArgs e) /// private void initAllDBManagers() { - Task.Factory.StartNew(() => + Task.Run(() => { AccountDBManager.INSTANCE.initManager(); ChatDBManager.INSTANCE.initManager(); diff --git a/UWP XMPP Client/Classes/BackgroundImageCache.cs b/UWP XMPP Client/Classes/BackgroundImageCache.cs index 97f25d41e..5fda99087 100644 --- a/UWP XMPP Client/Classes/BackgroundImageCache.cs +++ b/UWP XMPP Client/Classes/BackgroundImageCache.cs @@ -36,7 +36,7 @@ public static void loadCache() return; } - Task.WaitAny(Task.Factory.StartNew(async () => + Task.WaitAny(Task.Run(async () => { Logger.Info("Started loading background images..."); DateTime timeStart = DateTime.Now; diff --git a/UWP XMPP Client/Controls/AccountControl.xaml.cs b/UWP XMPP Client/Controls/AccountControl.xaml.cs index c6e64a29d..e166b40f8 100644 --- a/UWP XMPP Client/Controls/AccountControl.xaml.cs +++ b/UWP XMPP Client/Controls/AccountControl.xaml.cs @@ -253,7 +253,7 @@ private void disableAccount_tggls_Toggled(object sender, RoutedEventArgs e) { Account.disabled = !disableAccount_tggls.IsOn; XMPPAccount newAccount = Account.clone(); - Task.Factory.StartNew(() => AccountDBManager.INSTANCE.setAccountDisabled(newAccount, newAccount.disabled)); + Task.Run(() => AccountDBManager.INSTANCE.setAccountDisabled(newAccount, newAccount.disabled)); } } diff --git a/UWP XMPP Client/Controls/ChatDetailsControl.xaml.cs b/UWP XMPP Client/Controls/ChatDetailsControl.xaml.cs index e366f9760..d9db7a3ec 100644 --- a/UWP XMPP Client/Controls/ChatDetailsControl.xaml.cs +++ b/UWP XMPP Client/Controls/ChatDetailsControl.xaml.cs @@ -141,7 +141,7 @@ private void showMessages() chatMessages.AddRange(msgs); ChatTable cpy = Chat.clone(); - Task.Factory.StartNew(() => ChatDBManager.INSTANCE.markAllMessagesAsRead(cpy)); + Task.Run(() => ChatDBManager.INSTANCE.markAllMessagesAsRead(cpy)); } } @@ -344,7 +344,7 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (Chat != null && Equals(args.MESSAGE.chatId, Chat.id)) { - Task.Factory.StartNew(async () => + Task.Run(async () => { for (int i = 0; i < chatMessages.Count; i++) { diff --git a/UWP XMPP Client/Controls/ChatMasterControl.xaml.cs b/UWP XMPP Client/Controls/ChatMasterControl.xaml.cs index b84146efa..78470ab5d 100644 --- a/UWP XMPP Client/Controls/ChatMasterControl.xaml.cs +++ b/UWP XMPP Client/Controls/ChatMasterControl.xaml.cs @@ -476,7 +476,7 @@ private void autoEnter_tmfo_Click(object sender, RoutedEventArgs e) if (MUCInfo != null && MUCInfo.autoEnterRoom != autoEnter_tmfo.IsChecked) { MUCInfo.autoEnterRoom = autoEnter_tmfo.IsChecked; - Task.Factory.StartNew(() => MUCDBManager.INSTANCE.setMUCChatInfo(MUCInfo, false, false)); + Task.Run(() => MUCDBManager.INSTANCE.setMUCChatInfo(MUCInfo, false, false)); if (Chat.inRoster) { diff --git a/UWP XMPP Client/Controls/ServerFeaturesControl.xaml.cs b/UWP XMPP Client/Controls/ServerFeaturesControl.xaml.cs index bd94247a0..7f664becb 100644 --- a/UWP XMPP Client/Controls/ServerFeaturesControl.xaml.cs +++ b/UWP XMPP Client/Controls/ServerFeaturesControl.xaml.cs @@ -127,7 +127,7 @@ private void sendDiscoInfo() { discoInfosId = ""; Task t = Client.createDiscoAsync(Chat.chatJabberId, DiscoType.INFO); - Task.Factory.StartNew(async () => discoInfosId = await t); + Task.Run(async () => discoInfosId = await t); startTimerInfos(); } } @@ -138,7 +138,7 @@ private void sendDiscoItems() { discoItemsId = ""; Task t = Client.createDiscoAsync(Chat.chatJabberId, DiscoType.ITEMS); - Task.Factory.StartNew(async () => discoItemsId = await t); + Task.Run(async () => discoItemsId = await t); startTimerItems(); } } diff --git a/UWP XMPP Client/Dialogs/ClearCacheDialog.xaml.cs b/UWP XMPP Client/Dialogs/ClearCacheDialog.xaml.cs index 942cb3df6..0b33b862e 100644 --- a/UWP XMPP Client/Dialogs/ClearCacheDialog.xaml.cs +++ b/UWP XMPP Client/Dialogs/ClearCacheDialog.xaml.cs @@ -60,7 +60,7 @@ private void clearCache() bool mucMembers = (bool)mucMembers_chbx.IsChecked; bool reconnect = (bool)reconnect_chbx.IsChecked; - Task.Factory.StartNew(async () => + Task.Run(async () => { // General: if (chatMessages) diff --git a/UWP XMPP Client/Pages/ChatPage.xaml.cs b/UWP XMPP Client/Pages/ChatPage.xaml.cs index e1c286bff..220adb9f8 100644 --- a/UWP XMPP Client/Pages/ChatPage.xaml.cs +++ b/UWP XMPP Client/Pages/ChatPage.xaml.cs @@ -89,7 +89,7 @@ private void loadChats(string selectedChatId) allChats.Clear(); // Load all chats: - Task.Factory.StartNew(() => + Task.Run(() => { ChatTemplate selectedChat = null; @@ -248,7 +248,7 @@ private void ChatPage2_BackRequested(object sender, BackRequestedEventArgs e) private void INSTANCE_ChatChanged(ChatDBManager handler, Data_Manager.Classes.Events.ChatChangedEventArgs args) { - Task.Factory.StartNew(() => + Task.Run(() => { // Find chat in chatsList: foreach (ChatTemplate chatTemplate in allChats.Where((x) => x.chat != null && Equals(x.chat.id, args.CHAT.id))) @@ -295,7 +295,7 @@ private void INSTANCE_ChatChanged(ChatDBManager handler, Data_Manager.Classes.Ev private void INSTANCE_MUCInfoChanged(MUCDBManager handler, Data_Manager.Classes.Events.MUCInfoChangedEventArgs args) { - Task.Factory.StartNew(() => + Task.Run(() => { foreach (ChatTemplate chatTemplate in allChats.Where((x) => x.chat != null && x.chat.chatType == ChatType.MUC && Equals(x.chat.id, args.MUC_INFO.chatId))) { diff --git a/UWP XMPP Client/Pages/SettingsPages/AccountSettingsPage.xaml.cs b/UWP XMPP Client/Pages/SettingsPages/AccountSettingsPage.xaml.cs index 2b176abbe..a127b5852 100644 --- a/UWP XMPP Client/Pages/SettingsPages/AccountSettingsPage.xaml.cs +++ b/UWP XMPP Client/Pages/SettingsPages/AccountSettingsPage.xaml.cs @@ -48,7 +48,7 @@ public AccountSettingsPage() #region --Misc Methods (Private)-- private void loadAccounts() { - Task.Factory.StartNew(() => + Task.Run(() => { IList list = AccountDBManager.INSTANCE.loadAllAccounts(); diff --git a/UWP XMPP Client/Pages/SettingsPages/MiscSettingsPage.xaml.cs b/UWP XMPP Client/Pages/SettingsPages/MiscSettingsPage.xaml.cs index ca62a4646..243c6ff0c 100644 --- a/UWP XMPP Client/Pages/SettingsPages/MiscSettingsPage.xaml.cs +++ b/UWP XMPP Client/Pages/SettingsPages/MiscSettingsPage.xaml.cs @@ -52,7 +52,7 @@ public MiscSettingsPage() private void showImageChacheSize() { imageChacheSize_tblck.Text = "calculating..."; - Task.Factory.StartNew(async () => { + Task.Run(async () => { long size = await ImageDBManager.INSTANCE.getCachedImagesFolderSizeAsync(); string text = "~ "; if (size >= 1024) @@ -74,7 +74,7 @@ private void showImageChacheSize() private void showLogSize() { logSize_tblck.Text = "calculating..."; - Task.Factory.StartNew(async () => { + Task.Run(async () => { long size = await Logger.getLogFolderSizeAsync(); string text = "~ "; if (size >= 1024) diff --git a/XMPP_API/Classes/Network/TCP/TCPConnection.cs b/XMPP_API/Classes/Network/TCP/TCPConnection.cs index c3dad86b0..c7d1cbc85 100644 --- a/XMPP_API/Classes/Network/TCP/TCPConnection.cs +++ b/XMPP_API/Classes/Network/TCP/TCPConnection.cs @@ -246,7 +246,7 @@ public void startReaderTask() throw new InvalidOperationException("[TCPConnection]: Unable to start reader task! ConnectionState != Connected! state = " + state); } - Task.Factory.StartNew(() => + Task.Run(() => { string data = null; int errorCount = 0; diff --git a/XMPP_API/Classes/Network/XMPPConnection.cs b/XMPP_API/Classes/Network/XMPPConnection.cs index aab411ad7..aefb89f97 100644 --- a/XMPP_API/Classes/Network/XMPPConnection.cs +++ b/XMPP_API/Classes/Network/XMPPConnection.cs @@ -167,7 +167,7 @@ private async Task reconnectAsync() /// If the message got send delayed (e.g. stored in message cache). private void onMessageSend(string id, bool delayed) { - Task.Factory.StartNew(() => MessageSend?.Invoke(this, new MessageSendEventArgs(id, delayed))); + Task.Run(() => MessageSend?.Invoke(this, new MessageSendEventArgs(id, delayed))); } #endregion