private void InitializeTimer() { // We will use a DispatcherTimer to add records to the data periodically. // DispatcherTimer instead of Timer because bound data is closely associated with the UI thread. timer = new DispatcherTimer(); timer.Tick += new EventHandler(DispatcherTimer_Tick); timer.Interval = new TimeSpan(0, 0, 8); timer.Start(); } private static string GeneratePassword() { int length = (int)RandomNumber.Next(6, 22); string password = string.Empty; for (int i = 0; i < length; i++) { switch (RandomNumber.Next(0, 3)) { case 0: password += (char)RandomNumber.Next((int)'a', (int)'z'); break; case 1: password += (char)RandomNumber.Next((int)'A', (int)'Z'); break; case 2: password += (char)RandomNumber.Next((int)'0', (int)'9'); break; } } return password; } private void DispatcherTimer_Tick(object sender, EventArgs e) { foreach (var item in UsersObservableCollection) { item.Password = GeneratePassword(); } foreach (DataRow row in UsersDataTable.Rows) { row[1] = GeneratePassword(); } AddNextUser(); }}
Dusty On Development
SyntaxHighlighter
Saturday, 26 February 2011
Test
This is a general test of my blog, not anything useful yet.
Subscribe to:
Posts (Atom)