Last active
December 16, 2024 03:10
-
-
Save unitycoder/8721e5bd6377ac2ffbba4f9b0b2766f0 to your computer and use it in GitHub Desktop.
Revisions
-
unitycoder revised this gist
Aug 30, 2023 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,3 +21,8 @@ void YourMethod(System.Object a) }; Thread _thread = new Thread(starter) { IsBackground = true }; _thread.Start(); // call method in mainthread var mainThreadContext = System.Threading.SynchronizationContext.Current; mainThreadContext.Post(_ => YourFunction(), null); -
unitycoder revised this gist
Jan 28, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ ParameterizedThreadStart start = new ParameterizedThreadStart(YourMethod); myThread = new Thread(start); myThread.IsBackground = true; myThread.Start(yourParams); void YourMethod(System.Object a) { } -
unitycoder revised this gist
Jan 28, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ // send parameter to thread method Thread myThread; ParameterizedThreadStart start = new ParameterizedThreadStart(YourMethod); myThread = new Thread(start); myThread.IsBackground = true; -
unitycoder revised this gist
Nov 12, 2020 . 2 changed files with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,3 +11,11 @@ void YourMethod(System.Object a) Thread thread = new Thread(new ThreadStart(YourWorkMethod)); thread.Start(); // wait for thread to finish ThreadStart starter = YourMethod; starter += () => { Console.WriteLine("Done!"); }; Thread _thread = new Thread(starter) { IsBackground = true }; _thread.Start(); File renamed without changes. -
unitycoder revised this gist
Nov 15, 2019 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,13 @@ // send parameter to thread method ParameterizedThreadStart start = new ParameterizedThreadStart(YourMethod); myThread = new Thread(start); myThread.IsBackground = true; myfileStreamerThread.Start(yourParams); void YourMethod(System.Object a) { } // regular thread Thread thread = new Thread(new ThreadStart(YourWorkMethod)); thread.Start(); -
unitycoder revised this gist
Apr 8, 2019 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,8 @@ https://stackoverflow.com/a/16917271 for unity https://80.lv/articles/simple-multithreading-for-unity/ http://www.stevevermeulen.com/index.php/2017/09/using-async-await-in-unity3d-2017/ threading visualizer tool https://docs.microsoft.com/en-us/visualstudio/profiling/concurrency-visualizer?view=vs-2019 common bad patterns https://docs.microsoft.com/en-us/visualstudio/profiling/common-patterns-for-poorly-behaved-multithreaded-applications?view=vs-2019 -
unitycoder revised this gist
Feb 21, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,5 @@ setting priority, setting core https://stackoverflow.com/a/16917271 for unity https://80.lv/articles/simple-multithreading-for-unity/ http://www.stevevermeulen.com/index.php/2017/09/using-async-await-in-unity3d-2017/ -
unitycoder revised this gist
Feb 21, 2019 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ avoiding context switching https://social.msdn.microsoft.com/Forums/vstudio/en-US/ab44ec59-d695-41b5-8e47-1ddd204345ca/prevent-from-switching-to-another-thread?forum=csharpgeneral https://blogs.msdn.microsoft.com/andrewarnottms/2012/12/28/the-cost-of-context-switches/ https://docs.microsoft.com/en-us/dotnet/standard/threading/managed-threading-best-practices setting priority, setting core https://stackoverflow.com/a/16917271 for unity https://80.lv/articles/simple-multithreading-for-unity/ -
unitycoder created this gist
Nov 24, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ ParameterizedThreadStart start = new ParameterizedThreadStart(YourMethod); fileStreamerThread = new Thread(start); fileStreamerThread.IsBackground = true; fileStreamerThread.Start(yourParams); void YourMethod(System.Object a) { }