Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Program Freezing VB.NET

Posted on 2005-03-16
1
Medium Priority
?
409 Views
Last Modified: 2008-02-01
Hi,

I have a program that updates group membership.

It bascially updates a list of groups from a list box and loops until it finishes.

There is a status bar that display which groups it is updating.

The program interface freezes but it always finishes all the group updates.

I am looking for a way to make sure the program does not freeze and always shows what it is doing.

I have read about threading, would this solve the problem

an example of the code

For Each anItem In lstMembership.SelectedItems
                        Try
                            If CheckGroup(anItem) = False Then
                                If UpdateGroupMem(FullName(sUserE, sTree), FullName(anItem, sTree)) = True Then
                                    PrintLine(1, "Is Already a Member of " & anItem & " Group not Added")
                                    statInfo.Text = "Is Already a Member of " & anItem & " Group not Added"
                                    sLogError = sPath & "Log\" & sLogName & ".log"
                                    sAlready = True
                                Else
                                    PrintLine(1, anItem)
                                    statInfo.Text = anItem
                                End If
                            Else
                                MsgBox("Unable to Update Group: " & anItem & " Group is not allowed", MsgBoxStyle.Critical)
                            End If
                        Catch er As Exception
                            MsgBox(er.Message, MsgBoxStyle.Critical, "Add to Group")
                            FileClose(1)
                            Exit Sub
                        End Try

Many Thanks

Josh
0
Comment
Question by:supersuny2k
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 13553258
For Each anItem In lstMembership.SelectedItems
                        Try
                            If CheckGroup(anItem) = False Then
                                If UpdateGroupMem(FullName(sUserE, sTree), FullName(anItem, sTree)) = True Then
                                    PrintLine(1, "Is Already a Member of " & anItem & " Group not Added")
                                    statInfo.Text = "Is Already a Member of " & anItem & " Group not Added"
                                    sLogError = sPath & "Log\" & sLogName & ".log"
                                    sAlready = True
                                Else
                                    PrintLine(1, anItem)
                                    statInfo.Text = anItem
                                End If
                             
                                Application.DoEvents()       ' add this line to update window

                            Else
                                MsgBox("Unable to Update Group: " & anItem & " Group is not allowed", MsgBoxStyle.Critical)
                            End If
                        Catch er As Exception
                            MsgBox(er.Message, MsgBoxStyle.Critical, "Add to Group")
                            FileClose(1)
                            Exit Sub
                        End Try
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question