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

Chapter10 process exit #148

Closed
wants to merge 6 commits into from
Closed

Conversation

BenjaminMichaelis
Copy link
Member

No description provided.

@@ -22,13 +23,22 @@ public TemporaryFileStream()
Close();
}

Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:

catch(Exception exception)
{
//Write event to logs or UI
//...
}

after this from the book


#region IDisposable Members
public void Dispose()
{
Dispose(true);

// Turn off calling the finalizer
System.GC.SuppressFinalize(this);
Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:

// Unregister from the finalization queue
System.GC.SuppressFinalize(this);

@@ -67,8 +58,20 @@ public void Dispose(bool disposing)
if (disposing)
{
Stream?.Dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:

if(disposing)
{
Stream?.Close();
}

public static void Main(string[] args)
{
WriteLine("Starting...");
DoStuff();
Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:
line 14.5,

if (args.Any(arg => arg.ToLower() == "-gc"))
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
WriteLine("Exiting...");

{
WriteLine("Starting...");
SampleUnmanagedResource sampleUnmanagedResource =
new SampleUnmanagedResource();
Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:

REMOVE

 new SampleUnmanagedResource();

// ...
WriteLine("Exiting...");
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:
Replace lines 25-36 with

try
{
sampleUnmanagedResource =
new SampleUnmanagedResource();
// Use unmanaged resource.
// ...
}
finally
{
if (Environment.GetCommandLineArgs().Any(
arg => arg.ToLower() == "-dispose"))
{
sampleUnmanagedResource?.Dispose();
}
}
WriteLine("Exiting...");
// ...
}
}

}
}

public static class ConsoleLogger
Copy link
Member Author

Choose a reason for hiding this comment

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

To match v8.0 print:
Lines 107 to eof do not exist in print

@@ -7,7 +7,7 @@
using System.Threading;
Copy link
Member Author

Choose a reason for hiding this comment

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

This File is very different than v8.0 printing

@@ -1,5 +1,5 @@

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter20.Listing20_11
Copy link
Member Author

Choose a reason for hiding this comment

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

Very Different from v8.0 print

@@ -4,7 +4,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter20.Listing20_11
using System.Threading;
using System.Threading.Tasks;

class Program
Copy link
Member Author

Choose a reason for hiding this comment

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

Dont do this change, doesn't match v8.0 printing

@BenjaminMichaelis
Copy link
Member Author

Implemented in PR #151 instead to only take some of the changes

@BenjaminMichaelis BenjaminMichaelis deleted the Chapter10-ProcessExit branch January 21, 2021 19:23
BenjaminMichaelis added a commit that referenced this pull request Feb 3, 2021
Implementation of Chapter10 process exit PR #148
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.

2 participants