@@ -56,7 +56,7 @@ public enum EventSynchronizationStrategy
5656 /// <summary>
5757 /// SevenZip Extractor/Compressor base class. Implements Password string, ReportErrors flag.
5858 /// </summary>
59- public class SevenZipBase : MarshalByRefObject
59+ public abstract class SevenZipBase : MarshalByRefObject
6060 {
6161 private readonly string _password ;
6262 private readonly bool _reportErrors ;
@@ -68,24 +68,24 @@ public class SevenZipBase : MarshalByRefObject
6868 /// <summary>
6969 /// True if the instance of the class needs to be recreated in new thread context; otherwise, false.
7070 /// </summary>
71- protected internal bool NeedsToBeRecreated ;
71+ protected internal bool NeedsToBeRecreated ;
7272
7373 /// <summary>
7474 /// AsyncCallback implementation used in asynchronous invocations.
7575 /// </summary>
7676 /// <param name="ar">IAsyncResult instance.</param>
77- internal static void AsyncCallbackMethod ( IAsyncResult ar )
77+ internal static void AsyncCallbackMethod ( IAsyncResult ar )
7878 {
79- var result = ( AsyncResult ) ar ;
79+ var result = ( AsyncResult ) ar ;
8080 result . AsyncDelegate . GetType ( ) . GetMethod ( "EndInvoke" ) . Invoke ( result . AsyncDelegate , new [ ] { ar } ) ;
8181 ( ( SevenZipBase ) ar . AsyncState ) . ReleaseContext ( ) ;
8282 }
8383
8484 virtual internal void SaveContext (
8585#if ! DOTNET20
86- DispatcherPriority priority = DispatcherPriority . Normal
86+ DispatcherPriority priority = DispatcherPriority . Normal
8787#endif
88- )
88+ )
8989 {
9090#if ! DOTNET20
9191 Dispatcher = Dispatcher . CurrentDispatcher ;
@@ -109,7 +109,7 @@ virtual internal void ReleaseContext()
109109
110110 private delegate void EventHandlerDelegate < T > ( EventHandler < T > handler , T e ) where T : EventArgs ;
111111
112- internal void OnEvent < T > ( EventHandler < T > handler , T e , bool synchronous ) where T : EventArgs
112+ internal void OnEvent < T > ( EventHandler < T > handler , T e , bool synchronous ) where T : EventArgs
113113 {
114114 try
115115 {
@@ -126,7 +126,7 @@ internal void OnEvent<T>(EventHandler<T> handler, T e, bool synchronous) where T
126126 }
127127 if (
128128#if ! DOTNET20
129- Dispatcher == null
129+ Dispatcher == null
130130#else
131131 Context == null
132132#endif
@@ -222,6 +222,9 @@ public int UniqueID
222222
223223 private static int GetUniqueID ( )
224224 {
225+ lock ( Identificators )
226+ {
227+
225228 int id ;
226229 var rnd = new Random ( DateTime . Now . Millisecond ) ;
227230 do
@@ -231,6 +234,7 @@ private static int GetUniqueID()
231234 while ( Identificators . Contains ( id ) ) ;
232235 Identificators . Add ( id ) ;
233236 return id ;
237+ }
234238 }
235239
236240 #region Constructors
@@ -265,7 +269,11 @@ protected SevenZipBase(string password)
265269 /// </summary>
266270 ~ SevenZipBase ( )
267271 {
268- Identificators . Remove ( _uniqueID ) ;
272+ // This lock probably isn't necessary but just in case...
273+ lock ( Identificators )
274+ {
275+ Identificators . Remove ( _uniqueID ) ;
276+ }
269277 }
270278
271279 /// <summary>
@@ -331,7 +339,7 @@ internal bool ThrowException(CallbackBase handler, params Exception[] e)
331339 throw e [ 0 ] ;
332340 }
333341 return false ;
334- }
342+ }
335343
336344 internal void ThrowUserException ( )
337345 {
@@ -349,7 +357,7 @@ internal void ThrowUserException()
349357 /// <param name="handler">The class responsible for the callback.</param>
350358 internal void CheckedExecute ( int hresult , string message , CallbackBase handler )
351359 {
352- if ( hresult != ( int ) OperationResult . Ok || handler . HasExceptions )
360+ if ( hresult != ( int ) OperationResult . Ok || handler . HasExceptions )
353361 {
354362 if ( ! handler . HasExceptions )
355363 {
@@ -436,7 +444,7 @@ public override string ToString()
436444 type = "SevenZipCompressor" ;
437445 }
438446 return string . Format ( "{0} [{1}]" , type , _uniqueID ) ;
439- }
447+ }
440448 }
441449
442450 internal class CallbackBase : MarshalByRefObject
@@ -636,7 +644,7 @@ public struct ArchiveFileInfo
636644 /// <returns>true if the specified System.Object is equal to the current ArchiveFileInfo; otherwise, false.</returns>
637645 public override bool Equals ( object obj )
638646 {
639- return ( obj is ArchiveFileInfo ) ? Equals ( ( ArchiveFileInfo ) obj ) : false ;
647+ return ( obj is ArchiveFileInfo ) ? Equals ( ( ArchiveFileInfo ) obj ) : false ;
640648 }
641649
642650 /// <summary>
@@ -712,7 +720,7 @@ public struct ArchiveProperty
712720 /// <returns>true if the specified System.Object is equal to the current ArchiveProperty; otherwise, false.</returns>
713721 public override bool Equals ( object obj )
714722 {
715- return ( obj is ArchiveProperty ) ? Equals ( ( ArchiveProperty ) obj ) : false ;
723+ return ( obj is ArchiveProperty ) ? Equals ( ( ArchiveProperty ) obj ) : false ;
716724 }
717725
718726 /// <summary>
0 commit comments