473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

RAS Connection, one problem

I have used following code, it works for one time. As I want loop to work for 4 times. The code should dial number and show dialing status in Listbox. It do this for one time only. When It loop for second time, it do not show any dialing status in Listbox though dialing code executes(I saw thisin debug section).
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  2.         Dim th1 As New Threading.Thread(AddressOf Dialsub)
  3.         th1.IsBackground = True
  4.         th1.Start()
  5.  
  6.  
  7.     End Sub
  8.  
  9. Private Sub Dialsub()
  10.         For i As Integer = 0 To 4
  11.             sw.Start()
  12.             System.Threading.Thread.Sleep(5000)
  13.             sw.Stop()
  14.  
  15.             Dim tm As TimeSpan
  16.             tm = sw.Elapsed
  17.  
  18.             'MsgBox(tm.Seconds)
  19.  
  20.             If tm.Seconds = 4 Or tm.Seconds = 9 Then
  21.                 '  Dim rasconnection1 As New Ras.RasConnection
  22.  
  23.                 RasConnection1.PhoneNumber = "#777"
  24.                 RasConnection1.UserName = "vwireless@ptcl.com"
  25.                 RasConnection1.Password = "ptcl"
  26.                 RasConnection1.Dial()
  27.  
  28.  
  29.             End If
  30.             Button9.Text = i
  31.         Next
  32.     End Sub
  33.  
  34. Private Sub RasConnection1_DialNotify1(ByVal sender As Object, ByVal e As Ras.RasDialNotify1EventArgs) Handles RasConnection1.DialNotify1
  35.         ListBox1.Items.Add(String.Format("{0}", e.ConnectionState, e.Message.ToString))
  36.         If e.[Error] > 0 Then
  37.             MessageBox.Show(String.Format("{0},{1}", e.[Error], e.Message))
  38.         End If
  39.         ' RasConnection1.Dispose()
  40.  
  41.     End Sub
  42.  
Please me out to solve this.
Dec 7 '08 #1
3 2064
Ramk
61
Plz check the statement tm.Seconds = 4. It shall be 5sec because, you waited 5000ms=5sec at the statement System.Threading.Thread.Sleep(5000).
Do check the if tm.Seconds statement once again.Plz post your code segments in the [code] blocks(Just click # on your right top of the thread editor window.), which gives easy look at your code, thus can improve the response time.
Dec 7 '08 #2
@Ramk
Thanks RAMK for ur response...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  2. Dim th1 As New Threading.Thread(AddressOf Dialsub)
  3. th1.IsBackground = True
  4. th1.Start()
  5.  
  6.  
  7. End Sub
  8.  
  9. Private Sub Dialsub()
  10. For i As Integer = 0 To 4
  11. sw.Start()
  12. System.Threading.Thread.Sleep(5000)
  13. sw.Stop()
  14.  
  15. Dim tm As TimeSpan
  16. tm = sw.Elapsed
  17.  
  18. 'MsgBox(tm.Seconds)
  19.  
  20. If tm.Seconds = 4 Or tm.Seconds = 9 Then
  21. ' Dim rasconnection1 As New Ras.RasConnection
  22.  
  23. RasConnection1.PhoneNumber = "#777"
  24. RasConnection1.UserName = "vwireless@ptcl.com"
  25. RasConnection1.Password = "ptcl"
  26. RasConnection1.Dial()
  27.  
  28.  
  29. End If
  30. Button9.Text = i
  31. Next
  32. End Sub
  33.  
  34. Private Sub RasConnection1_DialNotify1(ByVal sender As Object, ByVal e As Ras.RasDialNotify1EventArgs) Handles RasConnection1.DialNotify1
  35. ListBox1.Items.Add(String.Format("{0}", e.ConnectionState, e.Message.ToString))
  36. If e.[Error] > 0 Then
  37. MessageBox.Show(String.Format("{0},{1}", e.[Error], e.Message))
  38. End If
  39. ' RasConnection1.Dispose()
  40.  
  41. End Sub
Well, I found the cause that is, when RasConnection1.Dial() executes, it get error, on next attempt it do not dial connection instead internally a error is raised that "Connection already being used", something like that. I tried rasconnection.dispose to dispose this control. But It do not dispose.

What should I do to dispose this RAS control? Is there any strong feature in VB.NET that dispose all threads of any control?

Thanks
Dec 7 '08 #3
Ramk
61
I tried rasconnection.dispose to dispose this control. But It do not dispose.

What should I do to dispose this RAS control? Is there any strong feature in VB.NET that dispose all threads of any control?

Thanks
How you are saying it is not disposed? I wouldn't understand. Try to use close method instead if such method exists. If you are having multiple threads, try to check the ThreadPool class can help you.
Dec 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there...
4
by: James | last post by:
We've had a recurring problem where all of a sudden we get a DBMSSOCN General Network Error on any page that connects to SQL Server. Then we have to reboot the server and everything works fine...
1
by: Mark | last post by:
I know that DB2 LUW version 8 has "connection pooling" that provides a connection concentrator (limits the number of simultaneous connections that can occur). But does it really provide connection...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
4
by: Rahul Anand | last post by:
Getting SQL Exception when trying to implement Connection based Trasaction using SQL Helper class. I am using the follwing function to execute my stored procs: -=-=-=- ExecuteScalar(ByVal...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.