GoGreen PC Tune-Up™
Learn More

this is how ssl encrypt our websites
MTNCOMP | List View | Table View | myBlog (1751 Entries)
myBlog Home


VB.Net and Visual C# random not so random, adjustment to codebase

by Mountain Computers Inc., Publication Date: Thursday, September 19, 2019

View Count: 769, Keywords: VB.Net, Visual C#, Random, Not So Random, Hashtags: #VB.Net #VisualC# #Random #NotSoRandom

we just used the process ID to help with the randomization by adding to the random value found plus the process ID integer to get away from the collisions we found in the random number generator.
our coding for a huge, and I mean huge internet based program function had a random generator function that did not end up being so random. if you have a multi-threaded, multi-processor, multi-connected application and utility working on a 100+ million record set and need random search and find and access results, do something like the following.
Imports System.Diagnostics
Imports System.IO
Imports System.Data.SqlClient
Imports System.Threading
Imports System.Net.Http
Imports System.Net
         Dim ProcID
        ProcID = Process.GetCurrentProcess().Id
        Debug.Print("ProcID = " & ProcID.ToString)
        ListStatus.Items.Add("ProcID = " & ProcID.ToString)

        Dim r
        Static Generator As System.Random = New System.Random()
        r = Generator.Next(1, maxDBrecords)
        r = r + ProcID
we cut away some of the code for while and looping but you get the idea.
the maxDBrecords was 118 million + and growing, so you can imagine our dilemma with collisions.
more to come...

if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.

© 2024 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.