Skip to content

Commit

Permalink
make threads option to user & add progress bar to follow the process
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdeLhalimSB committed Aug 31, 2023
1 parent 2eddf1c commit d430cef
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 8 deletions.
Binary file modified .vs/Crypto_Wallets_Scanner/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Crypto_Wallets_Scanner/Crypto_Wallets_Scanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="images\" />
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<Content Include="ethereum.ico" />
<Content Include="images\Screenshot.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
56 changes: 52 additions & 4 deletions Crypto_Wallets_Scanner/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions Crypto_Wallets_Scanner/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Crypto_Wallets_Scanner
Expand All @@ -22,6 +23,8 @@ public Main()
worker.ProgressChanged += Worker_ProgressChanged;
worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
}
private int selectedThreadCount = 1; // Default value


List<string> wallets = new List<string>();
string result = string.Empty;
Expand Down Expand Up @@ -78,8 +81,14 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)

int totalWallets = wallets.Count * blockchains.Count;
int progress = 0;
UpdateProgressBar(0);

ParallelOptions parallelOptions = new ParallelOptions
{
MaxDegreeOfParallelism = selectedThreadCount // Set the selected thread count
};

foreach (string wallet in wallets)
Parallel.ForEach(wallets, parallelOptions, wallet =>
{
for (int b = 0; b < blockchains.Count; b++)
{
Expand Down Expand Up @@ -119,7 +128,7 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
blockch = "MoonBeam";
result = ws.GetWalletBallance(wallet, blockchains[b], blockch, "availableBalanceDropdown");
}
else if(b == 7)
else if (b == 7)
{
blockch = "Cronos";
result = ws.GetWalletBallance(wallet, blockchains[b], blockch, "availableBalanceDropdown");
Expand All @@ -132,9 +141,22 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)

// Report progress and result to the UI thread
worker.ReportProgress((progress * 100) / totalWallets, result);

UpdateProgressBar((progress * 100) / totalWallets);
progress++;
}
});
}

private void UpdateProgressBar(int value)
{
// Make sure you invoke the UI update on the main thread
if (progressBar.InvokeRequired)
{
progressBar.Invoke(new Action<int>(UpdateProgressBar), value);
}
else
{
progressBar.Value = value;
}
}

Expand All @@ -158,5 +180,11 @@ private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
// Handle key press event if needed
}

private void threads_ValueChanged(object sender, EventArgs e)
{
selectedThreadCount = (int)threads_tx.Value;

}
}
}
Binary file modified Crypto_Wallets_Scanner/bin/Debug/Crypto_Wallets_Scanner.exe
Binary file not shown.
Binary file modified Crypto_Wallets_Scanner/bin/Debug/Crypto_Wallets_Scanner.pdb
Binary file not shown.
Binary file added Crypto_Wallets_Scanner/images/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified Crypto_Wallets_Scanner/obj/Debug/Crypto_Wallets_Scanner.exe
Binary file not shown.
Binary file modified Crypto_Wallets_Scanner/obj/Debug/Crypto_Wallets_Scanner.pdb
Binary file not shown.
Binary file not shown.

0 comments on commit d430cef

Please sign in to comment.