Skip to content

Assignment9+10 multithreading#101

Open
RyanHirte wants to merge 65 commits intoIntelliTect-Samples:Assignment9+10-Multithreadingfrom
ColtonKnopik:Assignment9+10-Multithreading
Open

Assignment9+10 multithreading#101
RyanHirte wants to merge 65 commits intoIntelliTect-Samples:Assignment9+10-Multithreadingfrom
ColtonKnopik:Assignment9+10-Multithreading

Conversation

@RyanHirte
Copy link
Copy Markdown

@RyanHirte RyanHirte commented Dec 3, 2025

Worked on with @ColtonKnopik

Extra credit implemented

RyanHirte and others added 30 commits November 22, 2025 18:24
        string hostNameOrAddress, CancellationToken cancellationToken = default)

    async public Task<PingResult> RunAsync(
        string hostNameOrAddress, CancellationToken cancellationToken = default)

implementations
My work on the assignment so far for 11/22
Copilot AI review requested due to automatic review settings December 3, 2025 16:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements multithreading functionality for a PingProcess class, adding async/await patterns, Task-based asynchronous methods, and parallel execution capabilities. The implementation includes comprehensive test coverage with a fake implementation for testing purposes.

Key Changes:

  • Implemented async variants of ping operations (RunAsync, RunTaskAsync, RunLongRunningAsync) with cancellation token support
  • Added parallel ping execution for multiple hosts with thread-safe output aggregation
  • Created comprehensive test suite with cross-platform support and a FakePingProcess for deterministic testing

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
Directory.Build.props Changed LangVersion to "latest" and added ParallelizeTestCollections setting
Assignment/PingProcess.cs New implementation with async methods, Task-based patterns, and parallel execution support
Assignment/Assignment/PingProcess.cs Removed old incomplete implementation
Assignment.Tests/PingProcessTests.cs Comprehensive test suite with async tests and cross-platform support
Assignment.Tests/FakePingProcess.cs Fake implementation for testing without actual network calls
Assignment.Tests/StringExtensions.cs Renamed method from IsLikeRegEx to IsLikeRegExPattern
Assignment.Tests/WildCardPattern.cs Added pragma directives to suppress warnings
Assignment.Tests/Assignment.Tests.csproj Added ParallelizeTestCollections setting
Assignment.Tests/AssemblyAttributes.cs Added assembly-level test parallelization configuration
Assignment/Assignment.Tests/PingProcessTests.cs Removed old test file (relocated)
Assignment/.gitignore Removed (likely consolidated to root level)
Assignment.sln Whitespace/formatting changes only
Assignment/Assignment.csproj Whitespace/formatting changes only
Comments suppressed due to low confidence (9)

Directory.Build.props:5

  • [nitpick] Changing LangVersion from a specific version (13.0) to latest can introduce breaking changes or unexpected behavior when the SDK is updated. The latest keyword means "the latest language version supported by this compiler," which could change without updating project files.

Consider using latestMajor instead, which provides new language features within the current major version without breaking changes, or stick to an explicit version number for more predictable builds.
Assignment/PingProcess.cs:132

  • Disposable 'ManualResetEventSlim' is created but not disposed.
            process.StartInfo.RedirectStandardOutput ? new(initialState: false) : null;

Assignment/PingProcess.cs:134

  • Disposable 'ManualResetEventSlim' is created but not disposed.
            process.StartInfo.RedirectStandardError ? new(initialState: false) : null;

Assignment.Tests/WildCardPattern.cs:152

  • These 'if' statements can be combined.
    Assignment.Tests/WildCardPattern.cs:362
  • These 'if' statements can be combined.
    Assignment.Tests/WildCardPattern.cs:622
  • These 'if' statements can be combined.
    Assignment.Tests/WildCardPattern.cs:255
  • Both branches of this 'if' statement return - consider using '?' to express intent better.
    Assignment.Tests/WildCardPattern.cs:383
  • Both branches of this 'if' statement return - consider using '?' to express intent better.
    Assignment.Tests/WildCardPattern.cs:1177
  • Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Assignment.Tests/PingProcessTests.cs Outdated
Comment thread Assignment/PingProcess.cs
Comment thread Assignment/PingProcess.cs Outdated
Comment thread Assignment/PingProcess.cs Outdated
Comment thread Assignment.Tests/PingProcessTests.cs
Comment thread Assignment/PingProcess.cs Outdated
Comment thread Assignment/PingProcess.cs Outdated
Comment thread Assignment/PingProcess.cs Outdated
Comment thread Assignment/PingProcess.cs
Comment thread Assignment.Tests/PingProcessTests.cs Outdated
Copy link
Copy Markdown

@BillMillerCoding BillMillerCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement PingProcess' public Task RunTaskAsync(string hostNameOrAddress) ✔
First implement public void RunTaskAsync_Success() test method to test PingProcess.RunTaskAsync() using "localhost". ✔
Do NOT use async/await in this implementation. ✔
Implement PingProcess' async public Task RunAsync(string hostNameOrAddress) ✔
First implement the public void RunAsync_UsingTaskReturn_Success() test method to test PingProcess.RunAsync() using "localhost" without using async/await. ✔
Also implement the async public Task RunAsync_UsingTpl_Success() test method to test PingProcess.RunAsync() using "localhost" but this time DO using async/await. ✔
Add support for an optional cancellation token to the PingProcess.RunAsync() signature. ✔ Inside the PingProcess.RunAsync() invoke the token's ThrowIfCancellationRequested() method so an exception is thrown. ✔ Test that, when cancelled from the test method, the exception thrown is an AggregateException ✔ with a TaskCanceledException inner exception ✔ using the test methods RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrapping ✔and RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrappingTaskCanceledException ✔ respectively.
Complete/fix AND test async public Task RunAsync(IEnumerable hostNameOrAddresses, CancellationToken cancellationToken = default) which executes ping for an array of hostNameOrAddresses (which can all be "localhost") in parallel, adding synchronization if needed. ✔ NOTE:
The order of the items in the stdOutput is irrelevant and expected to be intermingled.
StdOutput must have all the ping output returned (no lines can be missing) even though intermingled. ✔
Implement AND test public Task RunLongRunningAsync(ProcessStartInfo startInfo, Action<string?>? progressOutput, Action<string?>? progressError, CancellationToken token) using Task.Factory.StartNew() and invoking RunProcessInternal with a TaskCreation value of TaskCreationOptions.LongRunning and a TaskScheduler value of TaskScheduler.Current. Returning a Task is also okay. NOTE: This method does NOT use Task.Run. ✔
lace all shared project properties into a Directory.Build.Props file.
Place all shared project items into a Directory.Build.targets file.
Ensure nullable reference types is enabled ✔
Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
and enabled .NET analyzers for both projects ✔
For this assignment, consider using Assert.AreEqual() (the generic version) ✔
All of the above should be unit tested ✔
Choose simplicity over complexity ✔
Looks good, most of the stuff I would have thought to point out, Copilot pointed out

Copy link
Copy Markdown

@steeley21 steeley21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! You've misnamed/ are missing some of the requirements with the testing, however. Once you get those added I think you'll be in good shape.

Instructions

  1. Implement PingProcess' public Task RunTaskAsync(string hostNameOrAddress) ✔
    First implement public void RunTaskAsync_Success() test method to test PingProcess.RunTaskAsync() using "localhost". ❌
    Do NOT use async/await in this implementation. ❌
  2. Implement PingProcess' async public Task RunAsync(string hostNameOrAddress) ✔
    First implement the public void RunAsync_UsingTaskReturn_Success() test method to test PingProcess.RunAsync() using "localhost" without using async/await. ❌
    Also implement the async public Task RunAsync_UsingTpl_Success() test method to test PingProcess.RunAsync() using "localhost" but this time DO using async/await. ❌
  3. Add support for an optional cancellation token to the PingProcess.RunAsync() signature. ✔ Inside the PingProcess.RunAsync() invoke the token's ThrowIfCancellationRequested() method so an exception is thrown. ✔ Test that, when cancelled from the test method, the exception thrown is an AggregateException ❌ with a TaskCanceledException inner exception ❌ using the test methods RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrapping ❌and RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrappingTaskCanceledException ❌ respectively.
  4. Complete/fix AND test async public Task RunAsync(IEnumerable hostNameOrAddresses, CancellationToken cancellationToken = default) which executes ping for an array of hostNameOrAddresses (which can all be "localhost") in parallel, adding synchronization if needed. ✔ NOTE:
    The order of the items in the stdOutput is irrelevant and expected to be intermingled.
    StdOutput must have all the ping output returned (no lines can be missing) even though intermingled. ✔
  5. Implement AND test public Task RunLongRunningAsync(ProcessStartInfo startInfo, Action<string?>? progressOutput, Action<string?>? progressError, CancellationToken token) using Task.Factory.StartNew() and invoking RunProcessInternal with a TaskCreation value of TaskCreationOptions.LongRunning and a TaskScheduler value of TaskScheduler.Current. Returning a Task is also okay. NOTE: This method does NOT use Task.Run.✔

Extra Credit

Test and implement PingProcess.RunAsync(System.IProgress progess) so that you can capture the output as it occurs rather than capturing the output only when the process finishes. ✔

Fundamentals

Place all shared project properties into a Directory.Build.Props file.
Place all shared project items into a Directory.Build.targets file.
Ensure nullable reference types is enabled ✔
Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
and enabled .NET analyzers for both projects ✔
For this assignment, consider using Assert.AreEqual() (the generic version) ✔
All of the above should be unit tested ✔
Choose simplicity over complexity ✔

Comment thread Assignment.Tests/PingProcessTests.cs Outdated
Comment thread Assignment.Tests/PingProcessTests.cs Outdated
Comment thread Assignment.Tests/PingProcessTests.cs Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 5, 2025

Summary

Summary
Generated on: 12/05/2025 - 23:28:27
Coverage date: 12/05/2025 - 23:28:25
Parser: MultiReport (2x Cobertura)
Assemblies: 1
Classes: 2
Files: 1
Line coverage: 47% (81 of 172)
Covered lines: 81
Uncovered lines: 91
Coverable lines: 172
Total lines: 248
Branch coverage: 40% (28 of 70)
Covered branches: 28
Total branches: 70
Method coverage: Feature is only available for sponsors
Tag: 592_19978911116

Coverage

Assignment - 47%
Name Line Branch
Assignment 47% 40%
Assignment.PingProcess 46.7% 40%
Assignment.PingResult 100%

Copy link
Copy Markdown
Collaborator

@Joshua-Lester3 Joshua-Lester3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions

  1. Implement PingProcess' public Task<PingResult> RunTaskAsync(string hostNameOrAddress)
    • First implement public void RunTaskAsync_Success() test method to test PingProcess.RunTaskAsync() using "localhost". ✔
    • Do NOT use async/await in this implementation. ✔
  2. Implement PingProcess' async public Task<PingResult> RunAsync(string hostNameOrAddress)
    • First implement the public void RunAsync_UsingTaskReturn_Success() test method to test PingProcess.RunAsync() using "localhost" without using async/await. ✔
    • Also implement the async public Task RunAsync_UsingTpl_Success() test method to test PingProcess.RunAsync() using "localhost" but this time DO using async/await. ✔
  3. Add support for an optional cancellation token to the PingProcess.RunAsync() signature. ✔
    Inside the PingProcess.RunAsync() invoke the token's ThrowIfCancellationRequested() method so an exception is thrown. ✔
    Test that, when cancelled from the test method, the exception thrown is an AggregateException ✔ with a TaskCanceledException inner exception ✔ using the test methods RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrapping ✔and RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrappingTaskCanceledException ✔ respectively.
  4. Complete/fix AND test async public Task<PingResult> RunAsync(IEnumerable<string> hostNameOrAddresses, CancellationToken cancellationToken = default) which executes ping for an array of hostNameOrAddresses (which can all be "localhost") in parallel, adding synchronization if needed. ✔
    NOTE:
    • The order of the items in the stdOutput is irrelevant and expected to be intermingled.
    • StdOutput must have all the ping output returned (no lines can be missing) even though intermingled. ✔
  5. Implement AND test public Task<int> RunLongRunningAsync(ProcessStartInfo startInfo, Action<string?>? progressOutput, Action<string?>? progressError, CancellationToken token) using Task.Factory.StartNew() and invoking RunProcessInternal with a TaskCreation value of TaskCreationOptions.LongRunning and a TaskScheduler value of TaskScheduler.Current. Returning a Task<PingResult> is also okay. ❌ Didn't use TaskScheduler.Current.
    NOTE: This method does NOT use Task.Run.

Extra Credit

  • Test and implement PingProcess.RunAsync(System.IProgress<T> progess) so that you can capture the output as it occurs rather than capturing the output only when the process finishes. ✔

Fundamentals

  • Place all shared project properties into a Directory.Build.Props file.
  • Place all shared project items into a Directory.Build.targets file.
  • Ensure nullable reference types is enabled ✔
  • Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
  • Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
  • and enabled .NET analyzers for both projects ✔
  • For this assignment, consider using Assert.AreEqual<T>() (the generic version) ✔
  • All of the above should be unit tested ✔
  • Choose simplicity over complexity ✔

Comment thread Assignment/PingProcess.cs
},
token,
TaskCreationOptions.LongRunning,
TaskScheduler.Default);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskScheduler.Current is what is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants