Click here to Skip to main content
15,744,384 members

Comments by Matt T Heffron (Top 200 by date)

Matt T Heffron 2-Feb-22 18:27pm View    
This is not an issue of "optimizing" the code, but of debugging.
They are very different things and should never be confused!
"Optimizing" code that isn't working is, in my 40+ years of experience, ALWAYS the wrong thing to do!

"Classic" advice (but still quite appropriate)
The First Rule of Program Optimization:
Don’t do it.
The Second Rule of Program Optimization (for experts only!):
Don’t do it yet.
— Michael Jackson
Matt T Heffron 2-Feb-22 18:12pm View    
Also, your Stack(IEnumerable<t> collection) constructor, counts the items in the collection, and allocates the myList, but never puts them into myList!
Matt T Heffron 2-Feb-22 18:01pm View    
Your Pop() method never modifies your myList, so if you call it a second time it will return the same item again. You should not use a separate myStack. Just use myList.
Matt T Heffron 20-Aug-21 13:12pm View    
The stack trace in the Event Viewer information shows that the exception is being thrown from under the OnStartup():
Application: MyApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at MyApp.App.OnStartup(System.Windows.StartupEventArgs)
at System.Windows.Application.<.ctor>b__1_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at MyApp.App.Main()
Matt T Heffron 20-Aug-21 13:03pm View    
The message that I included was from the Windows Event Viewer. It didn't include the NAME of the file that it couldn't find.