Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Inresponsive program during an Active Directory search.

Inresponsive program during an Active Directory search.

Scheduled Pinned Locked Moved C#
helpquestionwindows-adminworkspace
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hardus Lombaard
    wrote on last edited by
    #1

    Below is some code that validates entries in a datagridview against entries in Active Directory and changes the color of the datagridview cells accordingly. A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive and the form doesn't refresh any longer until after the process is finished, thereby causing the progressbar to loose its functionality. How can I overcome this glitch? I would also like to implement a cancel button so that the user can cancel the validation process at any moment, but if a button is pressed I experience the problem mentioned above. Any help would be appreciated. Thanx. private void btnCheck_Click(object sender, EventArgs e) {                   using (DirectoryEntry de = new DirectoryEntry(adPath, adUsername, adPassword)) //))                                    {                         de.Username = Environment.UserName;                         de.AuthenticationType = AuthenticationTypes.Secure;                         //these are the attributes that will show                                       string[] attribs = new string[] { "displayName", "mail", "userAccountControl" };                         for (int x = 0; x < dgvManager.Rows.Count - 1; x++)                         {                               ValidateDetails(4, 5, 6, x, de, attribs); //Second in charge                               ValidateDetails(7, 8, 9, x, de, attribs); //Branch Manager

    M A 2 Replies Last reply
    0
    • H Hardus Lombaard

      Below is some code that validates entries in a datagridview against entries in Active Directory and changes the color of the datagridview cells accordingly. A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive and the form doesn't refresh any longer until after the process is finished, thereby causing the progressbar to loose its functionality. How can I overcome this glitch? I would also like to implement a cancel button so that the user can cancel the validation process at any moment, but if a button is pressed I experience the problem mentioned above. Any help would be appreciated. Thanx. private void btnCheck_Click(object sender, EventArgs e) {                   using (DirectoryEntry de = new DirectoryEntry(adPath, adUsername, adPassword)) //))                                    {                         de.Username = Environment.UserName;                         de.AuthenticationType = AuthenticationTypes.Secure;                         //these are the attributes that will show                                       string[] attribs = new string[] { "displayName", "mail", "userAccountControl" };                         for (int x = 0; x < dgvManager.Rows.Count - 1; x++)                         {                               ValidateDetails(4, 5, 6, x, de, attribs); //Second in charge                               ValidateDetails(7, 8, 9, x, de, attribs); //Branch Manager

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      Sounds like you need a background worker[^] Basically, its another thread but fairly easy to work with. The problem you are getting is that your current code is running on the UI thread thus causing issues with user interaction such as button clicks etc.

      Life goes very fast. Tomorrow, today is already yesterday.

      1 Reply Last reply
      0
      • H Hardus Lombaard

        Below is some code that validates entries in a datagridview against entries in Active Directory and changes the color of the datagridview cells accordingly. A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive and the form doesn't refresh any longer until after the process is finished, thereby causing the progressbar to loose its functionality. How can I overcome this glitch? I would also like to implement a cancel button so that the user can cancel the validation process at any moment, but if a button is pressed I experience the problem mentioned above. Any help would be appreciated. Thanx. private void btnCheck_Click(object sender, EventArgs e) {                   using (DirectoryEntry de = new DirectoryEntry(adPath, adUsername, adPassword)) //))                                    {                         de.Username = Environment.UserName;                         de.AuthenticationType = AuthenticationTypes.Secure;                         //these are the attributes that will show                                       string[] attribs = new string[] { "displayName", "mail", "userAccountControl" };                         for (int x = 0; x < dgvManager.Rows.Count - 1; x++)                         {                               ValidateDetails(4, 5, 6, x, de, attribs); //Second in charge                               ValidateDetails(7, 8, 9, x, de, attribs); //Branch Manager

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        Hardus Lombaard wrote:

        A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive

        You need to use Background worker in this case, which will help you show the progress of process with out any problem. Here is an sample application Using the BackgroundWorker Component in .NET 2 applications

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups