Thursday, April 12, 2012

Synchronous and asynchronous connection in

The application main thread is waiting for response of data base is called :"synchronous connection".In this the main thread is idle[no execution in the application] till database connectivity established. The main thread of application is not waiting for response of data base server is called "Asynchronous connection",In this case main thread will perform execution with in application with out waiting for data base response.It will improve the performance of application Asynchronous connection is recommended when the fallowed statement are not dependent on connection. 1.making connection with other data base 2.Performing remote nethod\3.Displaying form to accept data from user I will give an simple exam for how to implement the asynchronous connection using thread concept In this the asynchronous connection can be implemented to perform parallel implementation of data entry and data base connectivity.
Imports System.Data.Oledb
Imports System.Threading

public class form1

Dim cn As New OleDbConnection("provider=msdaora;user id=scott;password=tiger")
private sub connect()
Dim t As Thread
t=New Thread(address of connect)
//save button _click
if cn.State=ConnectionState.Open
Msgbox("wait for some time)
End If
End Sub

No comments: