File tree Expand file tree Collapse file tree 1 file changed +34
-19
lines changed Expand file tree Collapse file tree 1 file changed +34
-19
lines changed Original file line number Diff line number Diff line change 5
5
using System . Threading . Tasks ;
6
6
#endif
7
7
8
+ using Org . BouncyCastle . Utilities ;
9
+
8
10
namespace Org . BouncyCastle . Crypto . Prng
9
11
{
10
12
/**
@@ -71,36 +73,49 @@ private byte[] DoGenerateSeed(
71
73
ThreadPool . QueueUserWorkItem ( new WaitCallback ( Run ) ) ;
72
74
#endif
73
75
74
- for ( int i = 0 ; i < end ; i ++ )
76
+ #if PORTABLE
77
+ AutoResetEvent autoResetEvent = new AutoResetEvent ( false ) ;
78
+ #endif
79
+
80
+ try
75
81
{
76
- while ( this . counter == last )
82
+ for ( int i = 0 ; i < end ; i ++ )
77
83
{
78
- try
84
+ while ( this . counter == last )
79
85
{
86
+ try
87
+ {
80
88
#if PORTABLE
81
- new AutoResetEvent ( false ) . WaitOne ( 1 ) ;
89
+ autoResetEvent . WaitOne ( 1 ) ;
82
90
#else
83
- Thread . Sleep ( 1 ) ;
91
+ Thread . Sleep ( 1 ) ;
84
92
#endif
93
+ }
94
+ catch ( Exception )
95
+ {
96
+ // ignore
97
+ }
85
98
}
86
- catch ( Exception )
87
- {
88
- // ignore
89
- }
90
- }
91
99
92
- last = this . counter ;
100
+ last = this . counter ;
93
101
94
- if ( fast )
95
- {
96
- result [ i ] = ( byte ) last ;
97
- }
98
- else
99
- {
100
- int bytepos = i / 8 ;
101
- result [ bytepos ] = ( byte ) ( ( result [ bytepos ] << 1 ) | ( last & 1 ) ) ;
102
+ if ( fast )
103
+ {
104
+ result [ i ] = ( byte ) last ;
105
+ }
106
+ else
107
+ {
108
+ int bytepos = i / 8 ;
109
+ result [ bytepos ] = ( byte ) ( ( result [ bytepos ] << 1 ) | ( last & 1 ) ) ;
110
+ }
102
111
}
103
112
}
113
+ finally
114
+ {
115
+ #if PORTABLE
116
+ autoResetEvent . Close ( ) ;
117
+ #endif
118
+ }
104
119
105
120
this . stop = true ;
106
121
You can’t perform that action at this time.
0 commit comments