?
Solved

Program Freezing VB.NET

Posted on 2005-03-16
1
Medium Priority
?
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 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