<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Anthony Wong's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/anthonywong/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/anthonywong/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 04:41:26 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>WebException: Unable to read data from the transport connection</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/webexception-unable-to-read-data-from-the-transport-connection</link>
      <pubDate>Wed, 21 Nov 2007 14:41:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2007/11/21/webexception-unable-to-read-data-from-the-transport-connection/</guid>
      <description><![CDATA[A bug has been found on NETCF v2 and v35 that affects HTTPS web requests from Windows Mobile 6...]]></description>
      <content:encoded><![CDATA[<P>A bug has been found on NETCF v2 and v35 that affects HTTPS web requests from Windows Mobile 6 devices. Andrew has a <A class="" href="https://blogs.msdn.com/andrewarnottms/archive/2007/11/19/why-net-compact-framework-fails-to-call-some-https-web-servers.aspx" mce_href="https://blogs.msdn.com/andrewarnottms/archive/2007/11/19/why-net-compact-framework-fails-to-call-some-https-web-servers.aspx">blog article</A> about the cause of the issue in detail. The following is table listing whether the issue reproduces on a particular platform:</P>
<P mce_keep="true">
<TABLE class="" style="WIDTH: 316pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=420 border=0>
<COLGROUP>
<COL style="WIDTH: 101pt; mso-width-source: userset; mso-width-alt: 4900" width=134>
<COL style="WIDTH: 103pt; mso-width-source: userset; mso-width-alt: 5010" width=137>
<COL style="WIDTH: 112pt; mso-width-source: userset; mso-width-alt: 5449" width=149>
<TBODY>
<TR style="HEIGHT: 15.75pt" height=21>
<TD class=xl65 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; WIDTH: 101pt; BORDER-BOTTOM: white 1.5pt solid; HEIGHT: 15.75pt; BACKGROUND-COLOR: #4f81bd" width=134 height=21 class="xl65"><FONT face=Calibri color=#ffffff size=3><STRONG>OS</STRONG></FONT></TD>
<TD class=xl65 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; WIDTH: 103pt; BORDER-BOTTOM: white 1.5pt solid; BACKGROUND-COLOR: #4f81bd" width=137 class="xl65"><FONT face=Calibri color=#ffffff size=3><STRONG>V2 SP2 7045</STRONG></FONT></TD>
<TD class=xl66 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; WIDTH: 112pt; BORDER-BOTTOM: white 1.5pt solid; BACKGROUND-COLOR: #4f81bd" width=149 class="xl66"><STRONG><FONT face=Calibri color=#ffffff size=3>V35 RTM 7283</FONT></STRONG></TD></TR>
<TR style="HEIGHT: 15.75pt" height=21>
<TD class=xl67 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; HEIGHT: 15.75pt; BACKGROUND-COLOR: #b8cce4" height=21 class="xl67"><FONT face=Calibri size=3>PPC 2003</FONT></TD>
<TD class=xl67 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #b8cce4" class="xl67"><FONT face=Calibri size=3>Not repro</FONT></TD>
<TD class=xl68 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #b8cce4" class="xl68"><FONT face=Calibri size=3>Not repro</FONT></TD></TR>
<TR style="HEIGHT: 15pt" height=20>
<TD class=xl69 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; HEIGHT: 15pt; BACKGROUND-COLOR: #dbe5f1" height=20 class="xl69"><FONT face=Calibri size=3>WM5 PPC</FONT></TD>
<TD class=xl69 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #dbe5f1" class="xl69"><FONT face=Calibri size=3>Not repro</FONT></TD>
<TD class=xl70 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #dbe5f1" class="xl70"><FONT face=Calibri size=3>Not repro</FONT></TD></TR>
<TR style="HEIGHT: 15pt" height=20>
<TD class=xl67 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; HEIGHT: 15pt; BACKGROUND-COLOR: #b8cce4" height=20 class="xl67"><FONT face=Calibri size=3>WM6 PPC</FONT></TD>
<TD class=xl67 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #b8cce4" class="xl67"><FONT face=Calibri size=3>Repros</FONT></TD>
<TD class=xl68 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #b8cce4" class="xl68"><FONT face=Calibri size=3>Repros</FONT></TD></TR>
<TR style="HEIGHT: 15pt" height=20>
<TD class=xl69 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; HEIGHT: 15pt; BACKGROUND-COLOR: #dbe5f1" height=20 class="xl69"><FONT face=Calibri size=3>WinCE5 CEPC</FONT></TD>
<TD class=xl69 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #dbe5f1" class="xl69"><FONT face=Calibri size=3>Not repro</FONT></TD>
<TD class=xl70 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #dbe5f1" class="xl70"><FONT face=Calibri size=3>Not repro</FONT></TD></TR>
<TR style="HEIGHT: 15pt" height=20>
<TD class=xl67 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; HEIGHT: 15pt; BACKGROUND-COLOR: #b8cce4" height=20 class="xl67"><FONT face=Calibri size=3>WinCE6 CEPC</FONT></TD>
<TD class=xl67 style="BORDER-RIGHT: white 0.5pt solid; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #b8cce4" class="xl67"><FONT face=Calibri size=3>Not repro</FONT></TD>
<TD class=xl68 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: white 0.5pt solid; BACKGROUND-COLOR: #b8cce4" class="xl68"><FONT face=Calibri size=3>Not repro</FONT></TD></TR></TBODY></TABLE></P>
<P><FONT size=2>Cheers,</FONT></P>
<P><FONT size=2>Anthony Wong [MSFT]</FONT></P>
<P><FONT size=2>This posting is provided "AS IS" with no warranties, and confers no rights.</FONT>&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>How do I determine the application's root directory?</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/how-do-i-determine-the-applications-root-directory</link>
      <pubDate>Mon, 22 Jan 2007 15:31:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2007/01/22/how-do-i-determine-the-applications-root-directory/</guid>
      <description><![CDATA[This is a&nbsp;popular question in the forum. The answer used be&nbsp;part of NETCF FAQ...]]></description>
      <content:encoded><![CDATA[<SPAN>
<P><A title="aa497276.javascript:ShowHide('Avl3fsjij');"><U><FONT color=#0000ff></FONT></U></A></P>
<DIV id=Avl3fsjij>
<P>This is a&nbsp;popular question in the forum. The answer used be&nbsp;part of NETCF FAQ but&nbsp;cannot be easily located these days, so I would include the&nbsp;information here:&nbsp;</P>
<P>An application can determine the directory from which it was run by utilizing Reflection and easily modify it using IO.Path namespace.</P>
<P>[C#]</P>
<P><CODE>using System.Reflection;<BR>using System.IO;<BR><BR>// This is the full directory and exe name<BR>String fullAppName = Assembly.GetExecutingAssembly().GetName().CodeBase;<BR><BR>// This strips off the exe name<BR>String fullAppPath = Path.GetDirectoryName(fullAppName);</CODE></P>
<P><CODE>// This adds a file name to the path<BR>String fullFileName = Path.Combine(fullAppPath, "myfile.txt");<BR></P></CODE>
<P><CODE>From <A title=https://msdn2.microsoft.com/en-us/library/aa497276.aspx href="https://msdn2.microsoft.com/en-us/library/aa497276.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/aa497276.aspx">https://msdn2.microsoft.com/en-us/library/aa497276.aspx</A></CODE></P>
<P><CODE>Cheers,</CODE></P>
<P><CODE>Anthony Wong [MSFT]</CODE></P></DIV></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>Terminating a GPRS connection</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/terminating-a-gprs-connection</link>
      <pubDate>Fri, 27 Oct 2006 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/10/27/terminating-a-gprs-connection/</guid>
      <description><![CDATA[Earlier I have posted an article on establishing a GPRS/EVDO/EDGE connection with TcpClient in...]]></description>
      <content:encoded><![CDATA[<P>Earlier I have posted an article on establishing a GPRS/EVDO/EDGE connection with TcpClient in managed code. The post generated a number of questions from users and one of the common questions was that the code works them, but the connection remains open after the request has been closed. This is the behavior of Connection Manager, an OS component in Windows CE, in that on PPC and SP 2003 and later, the connection remains open even when we call ConnMgrReleaseConnection() passing in 0 as the second parameter. They probably base this behavior on the fact that connection is charged nowadays on the bandwidth used, not on the duration of the connection, and that keeping the connection open reduces the time needed for reestablishing the connection in case&nbsp;it is needed in future. In case you really need to close the connection for some reason, someone suggested you can use RasEnumConnections() followed by RasHangUp(), but I have not verified the calls and parameters needed for this.</P>]]></content:encoded>
    </item>
    <item>
      <title>SerialPort issue transmitting Unicode characters</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/serialport-issue-transmitting-unicode-characters</link>
      <pubDate>Tue, 25 Apr 2006 17:04:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/04/25/serialport-issue-transmitting-unicode-characters/</guid>
      <description><![CDATA[The managed implementation in .NET Framework 2.0 and .NET Compact Framework 2.0 supports the...]]></description>
      <content:encoded><![CDATA[<P>The managed implementation in .NET Framework 2.0 and .NET Compact Framework 2.0 supports the Encoding property that allows developers to specify the encoding they would use to transmit data over a serial port connection. The property defaults to ASCIIEncoding, which only allows ASCII characters to be transmitted. To transmit non-ASCII Unicode characters over the wire, developers may set the property to specify UTF8 or Unicode encodings. However, there is an issue in the implementation of SerialPort.ReadExisting() in V2 RTM that causes data corruption in some cases when Unicode characters are read. The issue reproduces against both NET FX 2.0 and NETCF 2.0.</P>
<P>To work around the issue, use SerialPort.Read instead of SerialPort.ReadExisting(). For example, if you have the following DataReceived event handler:</P>
<P>&nbsp; private void serial_DataReceived(object o, SerialDataReceivedEventArgs e)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; if (e.EventType == SerialData.Chars)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string str = m_port1.ReadExisting();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Process the returned string below<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }</P>
<P>Use the following code instead:</P>
<P>&nbsp; private void serial_DataReceived(object o, SerialDataReceivedEventArgs e)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; if (e.EventType == SerialData.Chars)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int bnread = m_port1.BytesToRead;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char[] a_char = new char[bnread];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int nread = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nread = m_port1.Read(a_char, 0, bnread);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string str = new string(a_char, 0, nread);<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Process the returned string below<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }</P>
<P>&nbsp;</P>
<P>Cheers,</P>
<P>Anthony Wong [MSFT]</P>
<P><FONT size=2>This posting is provided "AS IS" with no warranties, and confers no rights.</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>MessageBox issue</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/messagebox-issue</link>
      <pubDate>Wed, 12 Apr 2006 17:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/04/12/messagebox-issue/</guid>
      <description><![CDATA[On NETCF V2, a message box is automatically closed if MessageBox.Show() is called after a form is...]]></description>
      <content:encoded><![CDATA[<P><FONT size=2>On NETCF V2, a message box is automatically closed if MessageBox.Show() is called after a form is closed. This is different behavior from NETCF V1 and Desktop (V1/V2).</FONT></P>
<P><FONT size=2>To work around the issue, simply call Message.Show() on another thread with codes like this:</FONT></P>
<P><FONT size=2>In the Main() function, add the following lines after Application.Run():</FONT></P><FONT color=#008080>
<P><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread</FONT></FONT><FONT size=2> t = <FONT color=#0000ff>new</FONT> <FONT color=#008080>Thread</FONT>(<FONT color=#0000ff>new</FONT> <FONT color=#008080>ThreadStart</FONT>(DoWork));</FONT></P>
<P><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Start();</FONT></P>
<P><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Join();</FONT></P>
<P><FONT size=2>Add the following method to the Form class:</FONT></P><FONT color=#0000ff>
<P><FONT size=2>static</FONT></FONT><FONT size=2> <FONT color=#0000ff>void</FONT> DoWork()</FONT></P>
<P><FONT size=2>{</FONT></P>
<P><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MessageBox.Show(<FONT color=#800000>"finish"</FONT>);</FONT></P>
<P><FONT size=2>}</FONT></P>
<P><FONT size=2>Cheers,</FONT></P>
<P><FONT size=2>Anthony Wong [MSFT]</FONT></P>
<P><FONT size=2>This posting is provided "AS IS" with no warranties, and confers no rights.</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>Establish a GPRS connection with TcpClient</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/establish-a-gprs-connection-with-tcpclient</link>
      <pubDate>Mon, 13 Mar 2006 15:55:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/03/13/establish-a-gprs-connection-with-tcpclient/</guid>
      <description><![CDATA[NETCF's HttpWebRequest automatically sets up a GPRS connection for web requests/web services when a...]]></description>
      <content:encoded><![CDATA[<P>NETCF's HttpWebRequest automatically sets up a GPRS connection for web requests/web services when a wired/wi-fi connection is not available. Therefore, when you do a web request or consume a web service, developers do not need special coding to handle the GPRS connection case. This does not apply to lower level socket classes like TcpClient and UdpClient. With these classes, you would need to use the Connection Manager APIs to establish/release the connections.</P>
<P>To allow users to more easily setup/release a GPRS connection, I have written a managed representation of the connection manager APIs that we need when we establish a GPRS connection with TcpClient:</P><PRE>    public class GPRSConnection
    {
        const int S_OK = 0;
        const uint CONNMGR_PARAM_GUIDDESTNET = 0x1;
        const uint CONNMGR_FLAG_PROXY_HTTP = 0x1;
        const uint CONNMGR_PRIORITY_USERINTERACTIVE = 0x08000;
        const uint INFINITE = 0xffffffff;
        const uint CONNMGR_STATUS_CONNECTED = 0x10;
        static Hashtable ht = new Hashtable();

        static GPRSConnection()
        {
            ManualResetEvent mre = new ManualResetEvent(false);
            mre.Handle = ConnMgrApiReadyEvent();
            mre.WaitOne();
            CloseHandle(mre.Handle);
        }

        ~GPRSConnection()
        {
            ReleaseAll();
        }

        public static bool Setup(Uri url)
        {
            return Setup(url.ToString());
        }

        public static bool Setup(string urlStr)
        {
            ConnectionInfo ci = new ConnectionInfo();
            IntPtr phConnection = IntPtr.Zero;
            uint status = 0;

            if (ht[urlStr] != null)
                return true;

            if (ConnMgrMapURL(urlStr, ref ci.guidDestNet, IntPtr.Zero) != S_OK)
                return false;
            
            ci.cbSize = (uint) Marshal.SizeOf(ci);
            ci.dwParams = CONNMGR_PARAM_GUIDDESTNET;
            ci.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
            ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
            ci.bExclusive = 0;
            ci.bDisabled = 0;
            ci.hWnd = IntPtr.Zero;
            ci.uMsg = 0;
            ci.lParam = 0;

            if (ConnMgrEstablishConnectionSync(ref ci, ref phConnection, INFINITE, ref status) != S_OK &amp;&amp;
                status != CONNMGR_STATUS_CONNECTED)
                return false;

            ht[urlStr] = phConnection;
            return true;
        }

        public static bool Release(Uri url)
        {
            return Release(url.ToString());
        }

        public static bool Release(string urlStr)
        {
            return Release(urlStr, true);
        }

        private static bool Release(string urlStr, bool removeNode)
        {
            bool res = true;
            IntPtr ph = IntPtr.Zero;
            if (ht[urlStr] == null)
                return true;
            ph = (IntPtr)ht[urlStr];
            if (ConnMgrReleaseConnection(ph, 1) != S_OK)
                res = false;
            CloseHandle(ph);
            if (removeNode)
                ht.Remove(urlStr);
            return res;
        }

        public static void ReleaseAll()
        {
           foreach(DictionaryEntry de in ht)
           {
               Release((string)de.Key, false);
           }
           ht.Clear();
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct ConnectionInfo
        {
            public uint cbSize;
            public uint dwParams;
            public uint dwFlags;
            public uint dwPriority;
            public int bExclusive;
            public int bDisabled;
            public Guid guidDestNet;
            public IntPtr hWnd;
            public uint uMsg;
            public uint lParam;
            public uint ulMaxCost;
            public uint ulMinRcvBw;
            public uint ulMaxConnLatency;
        }

        [DllImport("cellcore.dll")]
        private static extern int ConnMgrMapURL(string pwszURL, ref Guid pguid, IntPtr pdwIndex);

        [DllImport("cellcore.dll")]
        private static extern int ConnMgrEstablishConnectionSync(ref ConnectionInfo ci, ref IntPtr phConnection, uint dwTimeout, ref uint pdwStatus);

        [DllImport("cellcore.dll")]
        private static extern IntPtr ConnMgrApiReadyEvent();

        [DllImport("cellcore.dll")]
        private static extern int ConnMgrReleaseConnection(IntPtr hConnection, int bCache);

        [DllImport("coredll.dll")]
        private static extern int CloseHandle(IntPtr hObject);
    }
</PRE>
<P>&nbsp;To use the GPRSConnection class, simply call the Setup method prior to creating a connection with the TcpClient() class. You may use the following sample as a reference to see how the class is used:</P>
<P>&nbsp;</P><PRE>        public void DoTcpConnection()
        {
            string url = "www.msn.com";
            bool res = GPRSConnection.Setup("https://" + url + "/");
            if (res)
            {
                TcpClient tc = new TcpClient(url, 80);
                NetworkStream ns = tc.GetStream();
                byte[] buf = new byte[100];
                ns.Write(buf, 0, 100);
                tc.Client.Shutdown(SocketShutdown.Both);
                ns.Close();
                tc.Close();
                MessageBox.Show("Wrote 100 bytes");
            }
            else
            {
                MessageBox.Show("Connection establishment failed");
            }
        }</PRE>
<P>Enjoy, </P>
<P>Anthony Wong [MSFT]</P>
<P>This posting is provided "AS IS" with no warranties, and confers no rights.</P>]]></content:encoded>
    </item>
    <item>
      <title>Deadlock issue on closing SerialPort</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/deadlock-issue-on-closing-serialport</link>
      <pubDate>Thu, 02 Mar 2006 21:02:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/03/02/deadlock-issue-on-closing-serialport/</guid>
      <description><![CDATA[NETCF V2's SerialPort implementation provides four public events for developers. They can add custom...]]></description>
      <content:encoded><![CDATA[<P>NETCF V2's SerialPort implementation provides four public events for developers. They can add custom event handlers to handle these events. Since these event handlers are executed by ThreadPool threads,&nbsp;if the developer wants to update form fields with the received data, he/she would need to invoke the associated methods on the form to ask the GUI thread owning the control to update itself.</P>
<P>The correct way to invoke the control update function is to use Control.BeginInvoke() instead of Control.Invoke(). This is because the serial port base stream is locked while&nbsp;serial port&nbsp;events are handled. If the serial port is closed (SerialPort.Close() called)&nbsp;with the GUI thread while the events are being handled (e.g. the user clicked a button to close the serial port, or the user exits the application), the serial port, as part of the port closing process, will attempt to acquire the lock on the base serial stream, and will wait until the lock is acquired. Therefore, the data event handler which has the lock will wait on the Control.Invoke() call for access to the GUI thread indefinitely, and the GUI thread will wait on the SerialPort.Close() call for access to the lock indefinitely.&nbsp;This causes a deadlock on the application, and the user will likely require a reset on the device to be able to rerun the application.</P>
<P>To prevent the issue,&nbsp;simply&nbsp;replace&nbsp;calls that might block for a long time on the serial port event handlers with non-blocking versions of the calls like Control.BeginInvoke().</P>
<P>This suggestion applies to the SerialPort implementation in both the compact and desktop versions of the .NET framework V2.</P>
<P>This posting is provided "AS IS" with no warranties, and confers no rights.</P>]]></content:encoded>
    </item>
    <item>
      <title>Directory.Exists() Issue</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/directory-exists-issue</link>
      <pubDate>Tue, 31 Jan 2006 13:13:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/01/31/directory-exists-issue/</guid>
      <description><![CDATA[On Windows CE 4.X based devices, Directory.Exists() treats path names ending with a slash "\"...]]></description>
      <content:encoded><![CDATA[<p>On Windows CE 4.X based devices, Directory.Exists() treats path names ending with a slash "\" differently. As an example,</p>
<p>Directory.Exists("\\temp")</p>
<p>will return true if the "temp" directory exists. However, the following call will return false even though the directory exists:</p>
<p>Directory.Exists("\\temp\\")</p>
<p>On Windows Mobile 5.0 devices, NETCF's behavior is consistent with Desktop's; that is, Directory.Exists() returns true if and only if the directory exists, no matter whether there is a trailing slash in the path or not. For the above example, we will return true for both calls if the directory exists.</p>
<p>Cheers,</p>
<p>Anthony Wong [MSFT]</p>
<p>This posting is provided "AS IS" with no warranties, and confers no rights.</p>]]></content:encoded>
    </item>
    <item>
      <title>Unhandled exception with serial port issue</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/unhandled-exception-with-serial-port-issue</link>
      <pubDate>Mon, 16 Jan 2006 14:13:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2006/01/16/unhandled-exception-with-serial-port-issue/</guid>
      <description><![CDATA[When an exception is unhandled in an application, an unhandled exception dialog is shown to inform...]]></description>
      <content:encoded><![CDATA[<P>When an exception is unhandled in an application, an unhandled exception dialog is shown to inform the user of the issue. Because of an issue in some serial port drivers, when an unhandled exception occurs and the user exits the application, the application is not&nbsp;actually closed if a serial port instance is open. However, this can be worked around by enclosing the application in a global try-catch block so that all exceptions are handled properly.</P>
<P>Cheers,</P>
<P>Anthony Wong [MSFT]</P>
<P>This posting is provided "AS IS" with no warranties, and confers no rights.</P>]]></content:encoded>
    </item>
    <item>
      <title>Bitmap.Save() Method</title>
      <link>https://docs.microsoft.com/archive/blogs/anthonywong/bitmap-save-method</link>
      <pubDate>Wed, 30 Nov 2005 20:31:00 GMT</pubDate>
      <dc:creator><![CDATA[Anthony Wong2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/anthonywong/2005/11/30/bitmap-save-method/</guid>
      <description><![CDATA[On pre-Windows Mobile 5.0 devices, because the image encoders are not available in the OS, NETCF V2...]]></description>
      <content:encoded><![CDATA[<P>On pre-Windows Mobile 5.0 devices, because the image encoders are not available in the OS, NETCF V2 does not support saving bitmaps into Gif, Jpeg or Png formats; only the Bmp format is supported. A NotSupportedException is thrown when you call the method&nbsp;on Pocket PC 2003 devices. All&nbsp;four file formats are supported in Windows Mobile 5.0.</P>
<P>Cheers,</P>
<P>Anthony Wong [MSFT]</P>
<P>This posting is provided "AS IS" with no warranties, and confers no rights. </P>]]></content:encoded>
    </item>
  </channel>
</rss>