Skip to content

Commit

Permalink
chore: add BG thread executor to the sample (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Jul 11, 2022
1 parent 004ef92 commit 266f79d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions samples/unity-of-bugs/Assets/Scenes/4_ThreadedSamples.unity
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ MonoBehaviour:
m_Image: {fileID: 0}
- m_Text: 'BG: Coroutine'
m_Image: {fileID: 0}
- m_Text: 'BG: Thread'
m_Image: {fileID: 0}
m_OnValueChanged:
m_PersistentCalls:
m_Calls:
Expand Down
5 changes: 5 additions & 0 deletions samples/unity-of-bugs/Assets/Scripts/ThreadingSamples.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Sentry;
using UnityEngine;
Expand Down Expand Up @@ -37,6 +38,10 @@ public void OnThreadingChange(int value)
name = "Background: Coroutine";
_executor = fn => StartCoroutine(Coroutine(fn));
break;
case 4:
name = "Background: Thread";
_executor = fn => new Thread(() => fn()).Start();
break;
default:
throw new ArgumentException($"Invalid threading dropdown value: {value}");

Expand Down

0 comments on commit 266f79d

Please sign in to comment.