3 Replies - 4059 Views - Last Post: 17 September 2012 - 12:52 PM Rate Topic: -----

#1 Neph1x   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 128
  • Joined: 19-November 11

Login System

Posted 15 September 2012 - 02:45 PM

I have one question!
Everything (login system) working fine for me, but why when i click button "Login" and when i checking if user exist in database, username, password blablabla why is my form let's say "blocked" "not responding" and when everything was checked it's working normally.

I ask you this because i wanna make when you click "Login" then i don't know maybe your button go invisible and i software show you maybe buffer picture Posted Image and there begins a problem because like i said when you click "Login" then everything is "laggy" etc,etc..

I wanna ask you can i set my login code (when software connecting to databse, checking users, blabla) to Background worker? or something like that, then my form would be fine and working properly.



Thank you very much! Sorry for my bad English.

Is This A Good Question/Topic? 0
  • +

Replies To: Login System

#2 lucky3   User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 233
  • View blog
  • Posts: 770
  • Joined: 19-October 11

Re: Login System

Posted 15 September 2012 - 10:07 PM

Quote

I wanna ask you can i set my login code (when software connecting to databse, checking users, blabla) to Background worker?


Yes you can set it to work in background, using BackgroundWorker for that. It will keep your UI responsive.
Was This Post Helpful? 0
  • +
  • -

#3 Neph1x   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 128
  • Joined: 19-November 11

Re: Login System

Posted 17 September 2012 - 11:53 AM

I getting this error when checking textbox.textlenght (username textbox)

ERROR

"Cross-thread operation not valid: Control 'username' accessed from a thread other than the thread it was created on."
Was This Post Helpful? 0
  • +
  • -

#4 lucky3   User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 233
  • View blog
  • Posts: 770
  • Joined: 19-October 11

Re: Login System

Posted 17 September 2012 - 12:52 PM

For that you need to use delegate:

    Delegate Sub TxtDelegate(ByVal txt As TextBox, ByVal message As String)
    Public Sub Txt_ThreadSafe(ByVal txt As TextBox, ByVal message As String)
        ' InvokeRequired required compares the thread ID of the calling thread to the thread ID of the creating thread.
        ' If these threads are different, it returns true.
        If txt.InvokeRequired = True Then
            Dim MyDelegate As New TxtDelegate(AddressOf Txt_ThreadSafe)
            Me.Invoke(MyDelegate, New Object() {txt, message})
        Else
            'you write your text
            txt.Text = message
        End If
    End Sub

'you call it simply with:
Sub Something()
    Txt_ThreadSafe(username, "your message") 'as your textbox is named username
End Sub


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1