| |

VerySource

 Forgot password?
 Register
Search
View: 1452|Reply: 11

Is this okay? Question about connection release?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-14 11:00:02
| Show all posts |Read mode
if (conn! = null)
                {
                    if (conn.State == ConnectionState.Connecting)
                        conn.Close ();
                    conn.Dispose ();
                }


What is the difference between ConnectionState.Connecting and ConnectionState.Close?
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-4-14 01:00:01
| Show all posts
Trying to connect (this value is reserved for future versions of VS2005)
Disabled
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-4-14 17:15:02
| Show all posts
One is trying to connect (for future version consideration)
One is the connection is closed
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-4-15 15:00:01
| Show all posts
Just close it, the GC will automatically recycle it, if not necessary, don't use Dispose ...

The opinions are for reference only.
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-16 09:45:01
| Show all posts
Using Yes, Dispose will always be called.
Reply

Use magic Report

0

Threads

38

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-4-16 18:15:01
| Show all posts
Dispose is generally not necessary,
.Close can be released to the connection pool
Reply

Use magic Report

2

Threads

29

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-4-17 19:45:01
| Show all posts
One using is enough, and convenient
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-5-2 13:45:02
| Show all posts
Would it be wrong if dispose was used?
Reply

Use magic Report

0

Threads

23

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-5-8 07:15:01
| Show all posts
Would it be wrong if dispose was used?
-------------
No mistake!
Reply

Use magic Report

0

Threads

13

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 Singapore

Post time: 2020-5-8 13:00:02
| Show all posts
With using, you do n’t need dispose, and using effect is also good
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list