Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed Issue #3 related to Running in the wrong thread. Fixed issue re…
…lated to "continue with" running late. Fixed some tests.
  • Loading branch information
NVentimiglia committed May 26, 2015
1 parent b2d93ed commit 0a8e84e
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 21 deletions.
Binary file not shown.
7 changes: 5 additions & 2 deletions Foundation Tasks/Assets/Foundation/Tasks/TaskTests.cs
Expand Up @@ -58,15 +58,18 @@ public IEnumerator Start()
Counter++;
Debug.Log("5 Continued");
});

yield return StartCoroutine(t5.WaitRoutine());
Assert(() => Counter == 7,7);
yield return new WaitForSeconds(1);

UnityTask.Run(() => { return "6 Run with Result And Continue"; }).ContinueWith(t => { Counter++; Debug.Log(t.Result); });
var t6 = UnityTask.Run(() => { return "6 Run with Result And Continue"; }).ContinueWith(t => { Counter++; Debug.Log(t.Result); });
yield return StartCoroutine(t6.WaitRoutine());
Assert(() => Counter == 8,8);
yield return new WaitForSeconds(1);

UnityTask.Run<string, string>(Test7, "7 Run with Param and Result And Continue").ContinueWith(t => { Counter++; Debug.Log(t.Result); });
var t7 = UnityTask.Run<string, string>(Test7, "7 Run with Param and Result And Continue").ContinueWith(t => { Counter++; Debug.Log(t.Result); });
yield return StartCoroutine(t7.WaitRoutine());
yield return new WaitForSeconds(1);
Assert(() => Counter == 10, 10);

Expand Down
33 changes: 33 additions & 0 deletions Foundation Tasks/Assets/Foundation/Tasks/TaskTests2.cs
@@ -0,0 +1,33 @@
using Foundation.Tasks;
using UnityEngine;
using System.Collections;

public class TaskTests2 : MonoBehaviour {

[ContextMenu("Work0")]
public void Work0()
{
// works, animation continues
UnityTask.Run(RealWork).ContinueWith(t => Debug.Log("Done!"));
}
[ContextMenu("Work1")]
public void Work1()
{
// does not work. animation freezes
UnityTask<bool>.Run<bool, bool>(RealWork, false).ContinueWith(t => Debug.Log("Done! " + t.Result));
}
private bool RealWork(bool test)
{
RealWork();
return test;
}
private void RealWork()
{
const int count = 5;
for (var y = 0; y < count; y++)
{
UnityTask.Delay(1000);
Debug.Log("Delay "+y);
}
}
}
Binary file modified Foundation Tasks/Assets/Plugins/Foundation.Tasks.dll
Binary file not shown.
Binary file modified Foundation Tasks/Assets/Plugins/WSA/Foundation.Tasks.Windows.dll
Binary file not shown.
Binary file modified Foundation Tasks/Assets/Plugins/WebGL/Foundation.Tasks.WebGL.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Foundation Tasks/ProjectSettings/ProjectVersion.txt
@@ -1,2 +1,2 @@
m_EditorVersion: 5.0.0p3
m_EditorVersion: 5.0.1f1
m_StandardAssetsVersion: 0
Binary file added Foundation.Tasks 5.26.2015.unitypackage
Binary file not shown.
2 changes: 1 addition & 1 deletion Foundation.Tasks/Foundation.Tasks.WebGL.csproj
Expand Up @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;UNITY_WEBGL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Foundation.Tasks/Foundation.Tasks.Windows.csproj
Expand Up @@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;UNITY_WSA</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down
Binary file modified Foundation.Tasks/Foundation.Tasks.v12.suo
Binary file not shown.
8 changes: 4 additions & 4 deletions Foundation.Tasks/Task.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
#if UNITY_WSA
using Windows.System.Threading;
Expand Down Expand Up @@ -136,8 +137,7 @@ public TaskStatus Status
if (_status == value)
return;
_status = value;



if (IsCompleted)
OnTaskComplete();
}
Expand Down Expand Up @@ -500,7 +500,7 @@ public virtual void Dispose()
/// <returns></returns>
public IEnumerator WaitRoutine()
{
while (IsRunning)
while (IsRunning || CompleteList.Count > 0)
{
yield return 1;
}
Expand All @@ -518,7 +518,7 @@ public UnityTask Wait()

Delay(10);

while (IsRunning)
while (IsRunning || CompleteList.Count > 0)
{
Delay(10);
}
Expand Down
12 changes: 0 additions & 12 deletions Foundation.Tasks/TaskTResult.cs
Expand Up @@ -72,12 +72,6 @@ public UnityTask(Func<TResult> function)
throw new ArgumentNullException("function");

_function = function;
Status = TaskStatus.Running;
#if UNITY_WEBGL
Execute();
#else
TaskManager.RunOnMainThread(Execute);
#endif
}

/// <summary>
Expand All @@ -91,12 +85,6 @@ public UnityTask(Delegate function, object param)

_function2 = function;
Paramater = param;
Status = TaskStatus.Running;
#if UNITY_WEBGL
Execute();
#else
TaskManager.RunOnMainThread(Execute);
#endif
}

/// <summary>
Expand Down
Binary file modified Foundation.Tasks/bin/Debug/Foundation.Tasks.WebGL.dll
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Debug/Foundation.Tasks.WebGL.pdb
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Debug/Foundation.Tasks.Windows.dll
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Debug/Foundation.Tasks.Windows.pdb
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Debug/Foundation.Tasks.dll
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Debug/Foundation.Tasks.pdb
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Release/Foundation.Tasks.Windows.dll
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Release/Foundation.Tasks.Windows.pdb
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Release/Foundation.Tasks.dll
Binary file not shown.
Binary file modified Foundation.Tasks/bin/Release/Foundation.Tasks.pdb
Binary file not shown.

0 comments on commit 0a8e84e

Please sign in to comment.