Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FixRecursiveLock #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions phirSOFT.JobManager.Core.Test/JobManagerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;

namespace phirSOFT.JobManager.Core.Test
{
[TestFixture]
class JobManagerTest
{

[Test]
public void TestOverAllStatus()
{
var manager = new JobManager();

Assert.AreEqual(false, manager.CanDisplayOverallProgress);
Assert.AreEqual(JobStatus.Succeded, manager.OverallStatus);
}
}
}
36 changes: 36 additions & 0 deletions phirSOFT.JobManager.Core.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("phirSOFT.JobManager.Core.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("phirSOFT.JobManager.Core.Test")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("359e1e52-ac74-41c4-976c-a57ac4235a00")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
5 changes: 5 additions & 0 deletions phirSOFT.JobManager.Core.Test/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.9.0" targetFramework="net46" />
<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net46" />
</packages>
68 changes: 68 additions & 0 deletions phirSOFT.JobManager.Core.Test/phirSOFT.JobManager.Core.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{359E1E52-AC74-41C4-976C-A57AC4235A00}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>phirSOFT.JobManager.Core.Test</RootNamespace>
<AssemblyName>phirSOFT.JobManager.Core.Test</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="JobManagerTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\phirSOFT.JobManager.Core\phirSOFT.JobManager.Core.csproj">
<Project>{3ce51311-b126-4aca-82b2-9875362c1ece}</Project>
<Name>phirSOFT.JobManager.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
</Project>
13 changes: 9 additions & 4 deletions phirSOFT.JobManager.Core/JobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public JobManager()

JobFinishedHandler = (sender, args) =>
{
if (((IJob) sender).Status == JobStatus.Succeded)
DeregisterJob((IJob) sender);
if (((IJob)sender).Status == JobStatus.Succeded)
DeregisterJob((IJob)sender);
};

_statusConverter = new JobStatusComparator();
Expand Down Expand Up @@ -81,8 +81,13 @@ public JobStatus OverallStatus
using (var enumerator = _registredJobs.GetEnumerator())
{
if (!enumerator.MoveNext())
{
_registredJobsLock.ExitReadLock();
return JobStatus.Succeded;

}


Debug.Assert(enumerator.Current != null, "enumerator.Current != null");
max = enumerator.Current.Status;
while (enumerator.MoveNext())
Expand All @@ -92,7 +97,7 @@ public JobStatus OverallStatus
max = enumerator.Current.Status;
}
}

_registredJobsLock.ExitReadLock();
return max;
}
}
Expand Down Expand Up @@ -152,7 +157,7 @@ IEnumerator IEnumerable.GetEnumerator()

private void OnJobPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var job = (IJob) sender;
var job = (IJob)sender;

switch (e.PropertyName)
{
Expand Down
6 changes: 6 additions & 0 deletions phirSOFT.JobManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "phirSOFT.JobManager.Core",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "phirSOFT.JobManager.Wpf", "phirSOFT.JobManager.Wpf\phirSOFT.JobManager.Wpf.csproj", "{A369D84E-7BB2-4F89-B1F2-07FCE871E783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "phirSOFT.JobManager.Core.Test", "phirSOFT.JobManager.Core.Test\phirSOFT.JobManager.Core.Test.csproj", "{359E1E52-AC74-41C4-976C-A57AC4235A00}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{A369D84E-7BB2-4F89-B1F2-07FCE871E783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A369D84E-7BB2-4F89-B1F2-07FCE871E783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A369D84E-7BB2-4F89-B1F2-07FCE871E783}.Release|Any CPU.Build.0 = Release|Any CPU
{359E1E52-AC74-41C4-976C-A57AC4235A00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{359E1E52-AC74-41C4-976C-A57AC4235A00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{359E1E52-AC74-41C4-976C-A57AC4235A00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{359E1E52-AC74-41C4-976C-A57AC4235A00}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down