Reusing the connection in ASP.NET |
Top Previous Next |
In a disconnected environment like ASP.NET, the Tn Pool allow to persist the Tn object on a session basis. Upon creation, Tn object generates an unique identifier that can be accessed through the SessionId property. When running under ASP.NET, this SessionId is set to the value of SessionId property belonging to the Session object. This allows to easily ask to the pool for a session´s Tn object.
VB.NET: Private Sub Page_Load() Dim telnet As Tn3270 = Tn3270.FromPool("Clemson",Session.SessionId) Try If Not telnet.IsConnected() Then telnet.Host = "clemson.clemson.edu" telnet.Port = 23 telnet.Connect(10000) End If ... Finally telnet.Release() End Try End Sub
C#: public void Page_Load() { Tn3270 telnet = Tn3270.FromPool("Clemson",Session.SessionId); try { if (!telnet.IsConnected()) { telnet.Host = "clemson.clemson.edu"; telnet.Port = 23; telnet.Connect(10000); } ... } finally { telnet.Release(); } }
|