FordGT90Concept
"I go fast!1!11!1!"
- Joined
- Oct 13, 2008
- Messages
- 26,259 (4.63/day)
- Location
- IA, USA
System Name | BY-2021 |
---|---|
Processor | AMD Ryzen 7 5800X (65w eco profile) |
Motherboard | MSI B550 Gaming Plus |
Cooling | Scythe Mugen (rev 5) |
Memory | 2 x Kingston HyperX DDR4-3200 32 GiB |
Video Card(s) | AMD Radeon RX 7900 XT |
Storage | Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM |
Display(s) | Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI) |
Case | Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay |
Audio Device(s) | Realtek ALC1150, Micca OriGen+ |
Power Supply | Enermax Platimax 850w |
Mouse | Nixeus REVEL-X |
Keyboard | Tesoro Excalibur |
Software | Windows 10 Home 64-bit |
Benchmark Scores | Faster than the tortoise; slower than the hare. |
I can't figure this one out.
Basically, the GUI has a "Generate" button which contains this code:
Here is StartPasswordGenerator():
As you can see, it creates eight asynchronous threads (or how many processors you got) at the end there. At this point, the GUI should be free to go about its updating. It should be idle except for the events hitting the update sub. But, it isn't. It's all locked up until it finishes.
Here's the code that does the majority of the updating:
I have verified the GUI elements are being updated but those updates aren't translating to the GUI.
Anyone have any ideas?
Basically, the GUI has a "Generate" button which contains this code:
Code:
if ((string)btnGenerate.Content == "Generate")
{
blkMessage.Text = "Started.";
_Attempts = 1;
_HasPassword = false;
[b]_Rules.StartPasswordGenerator();[/b]
btnGenerate.Content = "Stop";
}
else
{
_HasPassword = true;
_Rules.Halt();
blkMessage.Text = "User stopped.";
btnGenerate.Content = "Generate";
}
Here is StartPasswordGenerator():
Code:
_Stop = false;
Static.LengthMin = Convert.ToUInt16(MinimumLength.Text);
Static.LengthMax = Convert.ToUInt16(MaximumLength.Text);
Static.MaxAttempts = Convert.ToInt32(MaxAttempts.Text);
// Generate valid character list.
List<char> charlist = new List<char>();
if (AlphaLower.IsEnabled)
charlist.AddRange(AlphaLower.Text);
if (AlphaUpper.IsEnabled)
charlist.AddRange(AlphaUpper.Text);
if (Numeric.IsEnabled)
charlist.AddRange(Numeric.Text);
if (Special.IsEnabled)
charlist.AddRange(Special.Text);
Static.ValidChars = charlist.ToArray();
Static.Random = new Random();
for (int i = 0; i < Environment.ProcessorCount; i++)
{
_Threads[i] = new Thread(this.GeneratePassword);
_Threads[i].Start();
}
Here's the code that does the majority of the updating:
Code:
private void _Rules_AttemptFinished(string password)
{
if (blkMessage.Dispatcher.CheckAccess())
{
if (!_HasPassword)
{
if (_Attempts == Static.MaxAttempts)
{
_Rules.Halt();
prgPassword.Maximum = Static.MaxAttempts;
prgPassword.Value = _Attempts;
blkMessage.Text = "Max attempts reached. No password found matching the given requirements.";
btnGenerate.Content = "Generate";
}
else
{
prgPassword.Maximum = Static.MaxAttempts;
prgPassword.Value = _Attempts;
blkPassword.Text = _Attempts + "/" + Static.MaxAttempts + " (" + Math.Round(_Attempts / Static.MaxAttempts * (double)100, 2).ToString() + "%)";
_Attempts++;
}
}
}
else
blkMessage.Dispatcher.Invoke(new AttemptFinishedHandler(_Rules_AttemptFinished), password);
}
I have verified the GUI elements are being updated but those updates aren't translating to the GUI.
Anyone have any ideas?
Last edited: