<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2487169160564872308</id><updated>2026-07-19T05:43:58.284+05:30</updated><category term="c sharp"/><category term="vb.net"/><category term=".NET 6"/><category term=".net framework"/><category term="asp.net"/><category term="azure"/><category term="vb6"/><category term="Blazor"/><category term="Microsoft"/><category term="learning"/><category term="multi-threading"/><category term=".NET 8"/><category term="CAPTCHA"/><category term="DevOps"/><category term="One Note"/><category term="Power Automate"/><category term="Project Management"/><category term="SignalR"/><category term="Teams"/><category term="Windows 11"/><category term="ado.net"/><category term="alternativeto"/><category term="csharp"/><category term="dotnet"/><category term="erl"/><category term="error handling"/><category term="ftp"/><category term="graphics"/><category term="listbox"/><category term="network programming"/><category term="performance"/><category term="sendmessage"/><category term="tricks"/><category term="windows api"/><category term="windows service"/><title type='text'>.NET Talk</title><subtitle type='html'>My experiments in .NET</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-6184024968398645420</id><published>2024-10-18T23:10:00.004+05:30</published><updated>2024-10-18T23:23:51.840+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 8"/><category scheme="http://www.blogger.com/atom/ns#" term="Blazor"/><title type='text'>Boosting Performance with .NET 8 and Blazor</title><content type='html'>&lt;p&gt;As developers, we are always on the lookout for ways to optimize our applications, ensuring they run efficiently and deliver a smooth user experience. With the release of &lt;strong&gt;.NET 8&lt;/strong&gt;, Microsoft has introduced several enhancements, particularly in the &lt;strong&gt;Blazor&lt;/strong&gt; framework. This article explores some powerful techniques you can employ to boost the performance of your Blazor applications, including &lt;strong&gt;Ahead-of-Time (AOT) compilation&lt;/strong&gt;, &lt;strong&gt;lazy loading of assemblies&lt;/strong&gt;, and optimizing rendering processes.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; &lt;p&gt;&lt;/p&gt;
&lt;h2 id=&quot;understanding-blazor-and-its-architecture&quot;&gt;Understanding Blazor and Its Architecture&lt;/h2&gt;
&lt;p&gt;Blazor is a web framework that allows developers to build interactive web applications using C# instead of JavaScript. There are two hosting models available in Blazor: &lt;strong&gt;Blazor Server&lt;/strong&gt; and &lt;strong&gt;Blazor WebAssembly (WASM)&lt;/strong&gt;. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Blazor Server&lt;/strong&gt; operates on the server-side, while UI updates and event handling occur over a SignalR connection.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blazor WebAssembly&lt;/strong&gt;, on the other hand, runs entirely in the user&#39;s browser using WebAssembly, offering a more responsive user experience.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;aot-compilation-for-blazor-webassembly&quot;&gt;AOT Compilation for Blazor WebAssembly&lt;/h2&gt;
&lt;h3 id=&quot;what-is-aot-&quot;&gt;What is AOT?&lt;/h3&gt;
&lt;p&gt;Ahead-of-Time compilation allows your Blazor WebAssembly application to be pre-compiled, resulting in faster load times and improved runtime performance. By compiling the application to WebAssembly before deployment, you eliminate the need for Just-In-Time (JIT) compilation during execution.&lt;/p&gt;
&lt;h3 id=&quot;enabling-aot-in-net-8&quot;&gt;Enabling AOT in .NET 8&lt;/h3&gt;
&lt;p&gt;To enable AOT compilation in your Blazor WebAssembly project, you need to update the project file (.csproj) with the following properties:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;TargetFramework&lt;/span&gt;&amp;gt;&lt;/span&gt;net8.0&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;TargetFramework&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;RuntimeIdentifier&lt;/span&gt;&amp;gt;&lt;/span&gt;browser-wasm&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;RuntimeIdentifier&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;BlazorWebAssemblyEnableAot&lt;/span&gt;&amp;gt;&lt;/span&gt;true&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;BlazorWebAssemblyEnableAot&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;building-your-aot-compiled-application&quot;&gt;Building Your AOT-Compiled Application&lt;/h3&gt;
&lt;p&gt;Once you&#39;ve set up AOT in your project file, you can build your application using the following command:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-bash&quot;&gt;&lt;span class=&quot;hljs-symbol&quot;&gt;dotnet&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;build &lt;/span&gt;-c Release
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will generate the necessary WebAssembly files, enabling your application to run more efficiently in the browser.&lt;/p&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZaZWO2pZJFQ-tli6DfptArvaLeVwNAH4KZOTe1bGZZOqSZekCOGgsXgmUYisulWl17VjRoFgyKHdaUf9f4cI9P1_Hn3KDHy8EFF3zmPCcdSdTrsaKTbWKHmWhpyCJwdJ3zyLWoGM7da8RWLNDk3lTTGwVnams4ELDUTSiZ_VPDDQrwA8oBUr8-1QN4C30/s1792/Boosting%20Performance%20with%20.NET%208%20and%20Blazor.webp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1024&quot; data-original-width=&quot;1792&quot; height=&quot;366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZaZWO2pZJFQ-tli6DfptArvaLeVwNAH4KZOTe1bGZZOqSZekCOGgsXgmUYisulWl17VjRoFgyKHdaUf9f4cI9P1_Hn3KDHy8EFF3zmPCcdSdTrsaKTbWKHmWhpyCJwdJ3zyLWoGM7da8RWLNDk3lTTGwVnams4ELDUTSiZ_VPDDQrwA8oBUr8-1QN4C30/w640-h366/Boosting%20Performance%20with%20.NET%208%20and%20Blazor.webp&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 id=&quot;lazy-loading-of-assemblies&quot;&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2 id=&quot;lazy-loading-of-assemblies&quot;&gt;Lazy Loading of Assemblies&lt;/h2&gt;
&lt;h3 id=&quot;what-is-lazy-loading-&quot;&gt;What is Lazy Loading?&lt;/h3&gt;
&lt;p&gt;Lazy loading is a technique used to delay the loading of resources until they are needed. In Blazor applications, this can significantly improve the initial loading time by only loading assemblies and components when they are required.&lt;/p&gt;
&lt;h3 id=&quot;implementing-lazy-loading&quot;&gt;Implementing Lazy Loading&lt;/h3&gt;
&lt;p&gt;To implement lazy loading in your Blazor application, you can utilize the &lt;code&gt;Lazy&lt;/code&gt; component. Here’s a quick example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Define a component&lt;/strong&gt; you want to load lazily:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;lang-razor&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;&amp;lt;!-- MyLazyComponent.razor --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;This is a lazily loaded component!&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;Content goes here...&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Use the &lt;code&gt;Lazy&lt;/code&gt; component&lt;/strong&gt; to load it in another component:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;lang-razor&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;@page&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&quot;/lazy-load-example&quot;&lt;/span&gt;

&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Lazy Loading Example&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;Lazy @ref=&quot;lazyComponent&quot;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;Loading&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Loading...&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;/Loading&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;MyLazyComponent /&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;/Lazy&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;button @onclick=&quot;LoadLazyComponent&quot;&amp;gt;&lt;/span&gt;Load Lazy Component&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hljs-meta&quot;&gt;@code&lt;/span&gt; {
    private Lazy&lt;span class=&quot;hljs-variable&quot;&gt;&amp;lt;MyLazyComponent&amp;gt;&lt;/span&gt; lazyComponent;

    private void LoadLazyComponent()
    {
        lazyComponent.Load();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, the &lt;code&gt;MyLazyComponent&lt;/code&gt; will only load when the user clicks the button, optimizing the application&#39;s initial load time.&lt;/p&gt;
&lt;h2 id=&quot;optimizing-rendering-performance&quot;&gt;Optimizing Rendering Performance&lt;/h2&gt;
&lt;h3 id=&quot;using-the-key-directive&quot;&gt;Using the &lt;code&gt;@key&lt;/code&gt; Directive&lt;/h3&gt;
&lt;p&gt;One effective way to enhance the performance of your Blazor applications is by utilizing the &lt;code&gt;@key&lt;/code&gt; directive when rendering lists. This directive helps Blazor track changes to the items in the list more effectively.&lt;/p&gt;
&lt;p&gt;Here’s an example of how to use the &lt;code&gt;@key&lt;/code&gt; directive:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-razor&quot;&gt;@foreach (var &lt;span class=&quot;hljs-built_in&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; items)
{
    &amp;lt;&lt;span class=&quot;hljs-keyword&quot;&gt;div&lt;/span&gt; @key=&lt;span class=&quot;hljs-string&quot;&gt;&quot;item.Id&quot;&lt;/span&gt;&amp;gt;
        &amp;lt;h4&amp;gt;@&lt;span class=&quot;hljs-built_in&quot;&gt;item&lt;/span&gt;.Title&amp;lt;/h4&amp;gt;
        &amp;lt;p&amp;gt;@&lt;span class=&quot;hljs-built_in&quot;&gt;item&lt;/span&gt;.Description&amp;lt;/p&amp;gt;
    &amp;lt;/&lt;span class=&quot;hljs-keyword&quot;&gt;div&lt;/span&gt;&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By assigning a unique identifier to each item, Blazor can optimize the rendering process, minimizing unnecessary updates to the DOM.&lt;/p&gt;
&lt;h3 id=&quot;efficient-state-management&quot;&gt;Efficient State Management&lt;/h3&gt;
&lt;p&gt;Managing state efficiently is crucial for performance. Instead of using the built-in &lt;code&gt;@bind&lt;/code&gt; directive for complex forms, consider using a more explicit state management approach.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-razor&quot;&gt;&amp;lt;input type=&lt;span class=&quot;hljs-string&quot;&gt;&quot;text&quot;&lt;/span&gt; value=&lt;span class=&quot;hljs-string&quot;&gt;&quot;@userInput&quot;&lt;/span&gt; &lt;span class=&quot;hljs-meta&quot;&gt;@oninput&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;UpdateInput&quot;&lt;/span&gt; /&amp;gt;

&lt;span class=&quot;hljs-meta&quot;&gt;@code&lt;/span&gt; {
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; string userInput;

    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;UpdateInput&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(ChangeEventArgs e)&lt;/span&gt;
    &lt;/span&gt;{
        userInput = e.Value.ToString();
        &lt;span class=&quot;hljs-comment&quot;&gt;// Perform other operations as necessary&lt;/span&gt;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, we handle input changes explicitly, allowing for better control over state changes.&lt;/p&gt;
&lt;h2 id=&quot;additional-performance-tips&quot;&gt;Additional Performance Tips&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Minimize JavaScript Interop&lt;/strong&gt;: Blazor allows JavaScript interop, but excessive use can impact performance. Use it sparingly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enable HTTP/2&lt;/strong&gt;: If you host your application, ensure HTTP/2 is enabled to improve load times and reduce latency.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimize Images and Assets&lt;/strong&gt;: Use appropriate image formats and sizes to minimize load times.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Utilize Component Libraries&lt;/strong&gt;: Consider using pre-built component libraries like &lt;strong&gt;MudBlazor&lt;/strong&gt; or &lt;strong&gt;Radzen&lt;/strong&gt; to leverage optimized components.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;With .NET 8 and Blazor, developers have powerful tools at their disposal to create high-performance web applications. By implementing AOT compilation, utilizing lazy loading, and optimizing rendering processes, you can significantly enhance your application&#39;s responsiveness and user experience. &lt;/p&gt;
&lt;p&gt;Explore these features, and don&#39;t hesitate to experiment with your Blazor applications to see what works best for your specific use case!&lt;/p&gt;
&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8&quot;&gt;.NET 8 Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/aspnet/core/blazor/webassembly/performance?view=aspnetcore-8.0&quot;&gt;Blazor WebAssembly Performance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/aspnet/core/blazor/components/lazy-loading?view=aspnetcore-8.0&quot;&gt;Lazy Loading in Blazor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/aspnet/core/blazor/components/performance?view=aspnetcore-8.0&quot;&gt;Optimize Blazor Rendering Performance&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/6184024968398645420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/boosting-performance-with-net-8-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/6184024968398645420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/6184024968398645420'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/boosting-performance-with-net-8-and.html' title='Boosting Performance with .NET 8 and Blazor'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZaZWO2pZJFQ-tli6DfptArvaLeVwNAH4KZOTe1bGZZOqSZekCOGgsXgmUYisulWl17VjRoFgyKHdaUf9f4cI9P1_Hn3KDHy8EFF3zmPCcdSdTrsaKTbWKHmWhpyCJwdJ3zyLWoGM7da8RWLNDk3lTTGwVnams4ELDUTSiZ_VPDDQrwA8oBUr8-1QN4C30/s72-w640-h366-c/Boosting%20Performance%20with%20.NET%208%20and%20Blazor.webp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-330690472472337702</id><published>2024-10-18T09:15:00.001+05:30</published><updated>2024-10-18T09:15:06.883+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 6"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><title type='text'>Authentication in ASP.NET Core 6: Using JWT and OAuth2</title><content type='html'>&lt;p&gt;Modern web applications heavily rely on robust authentication mechanisms to secure user access and protect sensitive data. ASP.NET Core 6, a powerful framework for building web applications, offers various options for implementing secure authentication. This article delves into two prominent approaches: &lt;strong&gt;JSON Web Tokens (JWT)&lt;/strong&gt; and &lt;strong&gt;OAuth2&lt;/strong&gt;.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 id=&quot;understanding-authentication-in-asp-net-core-6&quot;&gt;Understanding Authentication in ASP.NET Core 6&lt;/h3&gt;
&lt;p&gt;Authentication verifies the identity of a user attempting to access an application resource. It confirms that the user is who they claim to be and grants them appropriate permissions based on their role. Here&#39;s a breakdown of the authentication process:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;User Login:&lt;/strong&gt; The user provides credentials (e.g., username, password) through a login form or API endpoint.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validation:&lt;/strong&gt; The application validates the credentials against a user store (e.g., database, Active Directory).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Token Generation (JWT):&lt;/strong&gt; If credentials are valid, the application generates a secure JWT containing user information and a digital signature.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Authorization:&lt;/strong&gt; Subsequent requests from the user include the JWT in the authorization header.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validation (JWT):&lt;/strong&gt; The application validates the JWT, ensuring its authenticity and integrity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access Control:&lt;/strong&gt; Based on the user&#39;s claims (roles, permissions) within the JWT, the application grants access to resources.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;jwt-json-web-token-for-authentication&quot;&gt;JWT (JSON Web Token) for Authentication&lt;/h3&gt;
&lt;p&gt;JWTs are self-contained, compact tokens that securely transmit information between parties. They consist of three Base64URL encoded parts separated by periods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Header:&lt;/strong&gt; Contains the token type (JWT) and signing algorithm used.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Payload:&lt;/strong&gt; Holds user claims (identity, roles, permissions) and expiration time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Signature:&lt;/strong&gt; Ensures the token&#39;s integrity and authenticity, generated using a cryptographic hash function and the issuer&#39;s secret key.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Benefits of JWTs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Stateless:&lt;/strong&gt; The server doesn&#39;t need to maintain user sessions, improving scalability and resilience.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Self-contained:&lt;/strong&gt; Information is encoded within the token, simplifying server-side storage requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security:&lt;/strong&gt; The signature ensures data integrity and prevents unauthorized modifications.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Considerations with JWTs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Client-side storage:&lt;/strong&gt; Exposes tokens to potential theft if not stored securely (e.g., HttpOnly cookies with HTTPS).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Token expiration:&lt;/strong&gt; Requires refreshing tokens before they expire to maintain seamless user experience.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validation complexity:&lt;/strong&gt; Applications need to validate token signatures and claims for security.&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4_lFzvk6tjpPnJJLoDmL3vkofYhQB35ACwgvoPubOQELYcSnhWz226GbH4TgVm1fNbutZXTMcCEluAA6sSCFVInWpPdEvClhkS0ZTSxzShXMHUfgoF2mEyrQwWPUBhqTiv4Bnf-iK-IwsHC_4cAvRCiA3sp-0JO8yNq-R1DiGFUfi_Z7pbiuXExkuj9N-/s2048/oauth.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2048&quot; data-original-width=&quot;2048&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4_lFzvk6tjpPnJJLoDmL3vkofYhQB35ACwgvoPubOQELYcSnhWz226GbH4TgVm1fNbutZXTMcCEluAA6sSCFVInWpPdEvClhkS0ZTSxzShXMHUfgoF2mEyrQwWPUBhqTiv4Bnf-iK-IwsHC_4cAvRCiA3sp-0JO8yNq-R1DiGFUfi_Z7pbiuXExkuj9N-/w640-h640/oauth.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h3 id=&quot;oauth2-for-authentication&quot;&gt;OAuth2 for Authentication&lt;/h3&gt;
&lt;p&gt;OAuth2 is an authorization framework used for delegating user authentication from a service provider (client application) to an authorization server. This allows users to log in with their existing credentials from a trusted provider (e.g., Google, Facebook) without needing separate accounts for each application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;OAuth2 Flow:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The user attempts to access a protected resource in the client application.&lt;/li&gt;
&lt;li&gt;The client application redirects the user to the authorization server&#39;s login page.&lt;/li&gt;
&lt;li&gt;The user logs in and grants permission to the client application to access their data.&lt;/li&gt;
&lt;li&gt;The authorization server redirects the user back to the client application with an authorization code.&lt;/li&gt;
&lt;li&gt;The client application exchanges the authorization code for an access token and (optional) refresh token from the authorization server.&lt;/li&gt;
&lt;li&gt;The client application uses the access token to access user resources on the resource server.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Benefits of OAuth2:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Improved Security:&lt;/strong&gt; Separates user authentication from application access control.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Centralized Identity Management:&lt;/strong&gt; Users manage logins on trusted providers, simplifying authentication workflows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Supports multiple client applications connecting to the same authorization server.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Considerations with OAuth2:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Increased Complexity:&lt;/strong&gt; Requires integration with an external authorization server, adding complexity to the system.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vendor Lock-in:&lt;/strong&gt; Reliance on a specific authorization server can limit flexibility.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;implementing-jwt-and-oauth2-in-asp-net-core-6&quot;&gt;Implementing JWT and OAuth2 in ASP.NET Core 6&lt;/h3&gt;
&lt;p&gt;ASP.NET Core 6 offers built-in features and libraries for implementing both JWT and OAuth2 authentication.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. JWT Authentication:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install the &lt;strong&gt;Microsoft.AspNetCore.Authentication.JwtBearer&lt;/strong&gt; NuGet package.&lt;/li&gt;
&lt;li&gt;Configure JWT settings (issuer, signing key, audience, etc.) in appsettings.json.&lt;/li&gt;
&lt;li&gt;Create a middleware class to validate JWTs and attach claims to user principal.&lt;/li&gt;
&lt;li&gt;Protect controllers or actions with the &lt;code&gt;[Authorize]&lt;/code&gt; attribute.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Microsoft Documentation: &lt;a href=&quot;https://learn.microsoft.com/en-us/aspnet/core/security/authentication/jwt-authn?view=aspnetcore-8.0&quot;&gt;https://learn.microsoft.com/en-us/aspnet/core/security/authentication/jwt-authn?view=aspnetcore-8.0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Tutorial: &lt;a href=&quot;https://codewithmukesh.com/blog/aspnet-core-api-with-jwt-authentication/&quot;&gt;https://codewithmukesh.com/blog/aspnet-core-api-with-jwt-authentication/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;2. OAuth2 Authentication:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Choose an external OAuth provider (e.g., Google, Facebook).&lt;/li&gt;
&lt;li&gt;Register your application with the provider to obtain client ID and secret.&lt;/li&gt;
&lt;li&gt;Install the relevant NuGet&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/330690472472337702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/authentication-in-aspnet-core-6-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/330690472472337702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/330690472472337702'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/authentication-in-aspnet-core-6-using.html' title='Authentication in ASP.NET Core 6: Using JWT and OAuth2'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4_lFzvk6tjpPnJJLoDmL3vkofYhQB35ACwgvoPubOQELYcSnhWz226GbH4TgVm1fNbutZXTMcCEluAA6sSCFVInWpPdEvClhkS0ZTSxzShXMHUfgoF2mEyrQwWPUBhqTiv4Bnf-iK-IwsHC_4cAvRCiA3sp-0JO8yNq-R1DiGFUfi_Z7pbiuXExkuj9N-/s72-w640-h640-c/oauth.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-8278352419033005621</id><published>2024-10-17T14:03:00.004+05:30</published><updated>2024-10-17T14:03:40.964+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 6"/><title type='text'>Mastering Dependency Injection in .NET 6</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;As software applications grow in complexity, managing dependencies becomes more challenging. &lt;strong&gt;Dependency Injection (DI)&lt;/strong&gt; is a design pattern that addresses this problem by decoupling components and improving the maintainability and testability of code. In &lt;strong&gt;.NET 6&lt;/strong&gt;, Dependency Injection is baked into the framework, making it easier than ever for developers to implement this best practice in their applications.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this article, we’ll explore the fundamentals of Dependency Injection, understand how it’s implemented in .NET 6, and learn how to master its use in real-world applications.&lt;/p&gt;
&lt;h2 id=&quot;what-is-dependency-injection-&quot;&gt;What is Dependency Injection?&lt;/h2&gt;
&lt;p&gt;Dependency Injection is a technique in which an object (or service) receives its dependencies from an external source, rather than creating them internally. This design pattern promotes loose coupling between components, making the system easier to modify, test, and extend.&lt;/p&gt;
&lt;p&gt;In simple terms, instead of a class creating its own dependencies (objects it interacts with), they are &quot;injected&quot; into the class. This way, the class doesn&#39;t depend on the concrete implementation of the dependencies, but on abstractions or interfaces.&lt;/p&gt;
&lt;h3 id=&quot;key-benefits-of-dependency-injection&quot;&gt;Key Benefits of Dependency Injection&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Loose Coupling&lt;/strong&gt;: Components are less dependent on the specific implementations of their dependencies, making it easier to swap them out when needed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testability&lt;/strong&gt;: By injecting mock dependencies during testing, it’s easier to isolate and test components.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maintainability&lt;/strong&gt;: Dependency Injection simplifies code maintenance by separating concerns. You can focus on the functionality of individual components without worrying about their dependencies.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;how-dependency-injection-works-in-net-6&quot;&gt;How Dependency Injection Works in .NET 6&lt;/h2&gt;
&lt;p&gt;In .NET 6, Dependency Injection is built into the framework. ASP.NET Core, Blazor, and many other .NET-based applications rely heavily on DI to inject services into controllers, classes, and other components.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMK4eGEKvotQGw_dzmqV64oJimrmnhEukCOw-y7px2Ih-lqBX3l58VSaLO2Y-vEajP5HmmMXESbsZkaie2EEDJyushbstjfYpS4Q1XDfyuIipeTQWM21NuFBIIOfAwRwTtpdn5IC3sNSLYrSsU_gdaxs96n4wLpYuj8XQKqP0F4xprDGNxwQ2M6kOyYvbH/s1280/coding-computer-data-depth-of-field-577585.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;959&quot; data-original-width=&quot;1280&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMK4eGEKvotQGw_dzmqV64oJimrmnhEukCOw-y7px2Ih-lqBX3l58VSaLO2Y-vEajP5HmmMXESbsZkaie2EEDJyushbstjfYpS4Q1XDfyuIipeTQWM21NuFBIIOfAwRwTtpdn5IC3sNSLYrSsU_gdaxs96n4wLpYuj8XQKqP0F4xprDGNxwQ2M6kOyYvbH/w640-h480/coding-computer-data-depth-of-field-577585.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-three-di-lifetimes&quot;&gt;The Three DI Lifetimes&lt;/h3&gt;
&lt;p&gt;.NET 6 supports three types of lifetimes for services, determining how and when the dependencies are created and disposed of:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Singleton&lt;/strong&gt;: A single instance of the service is created and shared across the entire application’s lifetime. This is useful for services that maintain state throughout the app, like logging services or configuration handlers.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;services.&lt;span class=&quot;hljs-keyword&quot;&gt;AddSingleton&amp;lt;IMyService, &lt;/span&gt;MyService&amp;gt;()&lt;span class=&quot;hljs-comment&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scoped&lt;/strong&gt;: A new instance of the service is created per request. In web applications, this means a new instance is created for each HTTP request. This is ideal for services that are tied to the lifecycle of a request, such as database context classes.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;services.&lt;span class=&quot;hljs-keyword&quot;&gt;AddScoped&amp;lt;IMyService, &lt;/span&gt;MyService&amp;gt;()&lt;span class=&quot;hljs-comment&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Transient&lt;/strong&gt;: A new instance of the service is created each time it’s requested. This is suitable for lightweight, stateless services where each use requires a fresh instance.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;services.&lt;span class=&quot;hljs-keyword&quot;&gt;AddTransient&amp;lt;IMyService, &lt;/span&gt;MyService&amp;gt;()&lt;span class=&quot;hljs-comment&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Understanding the appropriate lifetime for your services is crucial for efficient resource management and application performance.&lt;/p&gt;
&lt;h2 id=&quot;setting-up-dependency-injection-in-net-6&quot;&gt;Setting Up Dependency Injection in .NET 6&lt;/h2&gt;
&lt;p&gt;Let’s walk through the basic setup of Dependency Injection in a .NET 6 application.&lt;/p&gt;
&lt;h3 id=&quot;step-1-define-the-service-and-interface&quot;&gt;Step 1: Define the Service and Interface&lt;/h3&gt;
&lt;p&gt;First, create an interface and a corresponding service that implements it. For this example, let’s create a simple logging service.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;ILoggerService&lt;/span&gt;
{
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Log&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;string&lt;/span&gt; message&lt;/span&gt;)&lt;/span&gt;;
}

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;LoggerService&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;ILoggerService&lt;/span&gt;
{
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Log&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;string&lt;/span&gt; message&lt;/span&gt;)
    &lt;/span&gt;{
        Console.WriteLine(&lt;span class=&quot;hljs-string&quot;&gt;$&quot;Log: &lt;span class=&quot;hljs-subst&quot;&gt;{message}&lt;/span&gt;&quot;&lt;/span&gt;);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, &lt;code&gt;ILoggerService&lt;/code&gt; is the interface, and &lt;code&gt;LoggerService&lt;/code&gt; is the concrete implementation that logs messages to the console.&lt;/p&gt;
&lt;h3 id=&quot;step-2-register-the-service-in-the-dependency-injection-container&quot;&gt;Step 2: Register the Service in the Dependency Injection Container&lt;/h3&gt;
&lt;p&gt;In .NET 6, services are registered in the &lt;strong&gt;Program.cs&lt;/strong&gt; file (which replaces &lt;code&gt;Startup.cs&lt;/code&gt; from earlier versions). You register your services by adding them to the DI container using the &lt;code&gt;AddSingleton&lt;/code&gt;, &lt;code&gt;AddScoped&lt;/code&gt;, or &lt;code&gt;AddTransient&lt;/code&gt; methods, depending on the service lifetime you need.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; builder = WebApplication.CreateBuilder(&lt;span class=&quot;hljs-keyword&quot;&gt;args&lt;/span&gt;);

&lt;span class=&quot;hljs-comment&quot;&gt;// Register the LoggerService as a singleton&lt;/span&gt;
builder.Services.AddSingleton&amp;lt;ILoggerService, LoggerService&amp;gt;();

&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;app&lt;/span&gt; = builder.Build();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, &lt;code&gt;LoggerService&lt;/code&gt; is registered as a singleton, meaning only one instance will be created and reused across the application.&lt;/p&gt;
&lt;h3 id=&quot;step-3-inject-the-service-into-your-components&quot;&gt;Step 3: Inject the Service into Your Components&lt;/h3&gt;
&lt;p&gt;Once the service is registered, you can inject it into any class or controller by using constructor injection. For example, let’s inject the &lt;code&gt;ILoggerService&lt;/code&gt; into a controller:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;HomeController&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;Controller&lt;/span&gt;
{
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;readonly&lt;/span&gt; ILoggerService _logger;

    &lt;span class=&quot;hljs-comment&quot;&gt;// Inject ILoggerService via constructor&lt;/span&gt;
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;HomeController&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;ILoggerService logger&lt;/span&gt;)
    &lt;/span&gt;{
        _logger = logger;
    }

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; IActionResult &lt;span class=&quot;hljs-title&quot;&gt;Index&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;)
    &lt;/span&gt;{
        _logger.Log(&lt;span class=&quot;hljs-string&quot;&gt;&quot;Handling Index action&quot;&lt;/span&gt;);
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; View();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, the &lt;code&gt;HomeController&lt;/code&gt; class receives an instance of &lt;code&gt;ILoggerService&lt;/code&gt; via its constructor. The DI container automatically resolves this dependency and injects the registered &lt;code&gt;LoggerService&lt;/code&gt; instance when the controller is instantiated.&lt;/p&gt;
&lt;h2 id=&quot;advanced-dependency-injection-techniques&quot;&gt;Advanced Dependency Injection Techniques&lt;/h2&gt;
&lt;p&gt;Now that we’ve covered the basics, let’s dive into some more advanced Dependency Injection techniques in .NET 6.&lt;/p&gt;
&lt;h3 id=&quot;1-injecting-multiple-implementations-of-the-same-interface-&quot;&gt;1. &lt;strong&gt;Injecting Multiple Implementations of the Same Interface&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Sometimes, you may need to register and inject multiple implementations of the same interface. For example, you might have different logging services that log to different destinations (e.g., console, file, or a database).&lt;/p&gt;
&lt;p&gt;To handle this, you can register multiple implementations and use &lt;strong&gt;named services&lt;/strong&gt; or &lt;strong&gt;keyed services&lt;/strong&gt; to resolve them at runtime.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-selector-tag&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.Services&lt;/span&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.AddTransient&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-selector-tag&quot;&gt;ILoggerService&lt;/span&gt;, &lt;span class=&quot;hljs-selector-tag&quot;&gt;ConsoleLoggerService&lt;/span&gt;&amp;gt;();
&lt;span class=&quot;hljs-selector-tag&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.Services&lt;/span&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.AddTransient&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-selector-tag&quot;&gt;ILoggerService&lt;/span&gt;, &lt;span class=&quot;hljs-selector-tag&quot;&gt;FileLoggerService&lt;/span&gt;&amp;gt;();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To inject all implementations, you can inject an &lt;code&gt;IEnumerable&lt;/code&gt; of the service type:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;HomeController&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;Controller&lt;/span&gt;
{
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;readonly&lt;/span&gt; IEnumerable&amp;lt;ILoggerService&amp;gt; _loggers;

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;HomeController&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;IEnumerable&amp;lt;ILoggerService&amp;gt; loggers&lt;/span&gt;)
    &lt;/span&gt;{
        _loggers = loggers;
    }

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; IActionResult &lt;span class=&quot;hljs-title&quot;&gt;Index&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;)
    &lt;/span&gt;{
        &lt;span class=&quot;hljs-keyword&quot;&gt;foreach&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; logger &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; _loggers)
        {
            logger.Log(&lt;span class=&quot;hljs-string&quot;&gt;&quot;Handling Index action&quot;&lt;/span&gt;);
        }
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; View();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;2-injecting-services-in-middleware-&quot;&gt;2. &lt;strong&gt;Injecting Services in Middleware&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In ASP.NET Core applications, middleware components often require services to handle specific logic. You can inject services directly into your custom middleware by passing them as parameters in the constructor.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;RequestLoggingMiddleware&lt;/span&gt;
{
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;readonly&lt;/span&gt; RequestDelegate _next;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;readonly&lt;/span&gt; ILoggerService _logger;

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;RequestLoggingMiddleware&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;RequestDelegate next, ILoggerService logger&lt;/span&gt;)
    &lt;/span&gt;{
        _next = next;
        _logger = logger;
    }

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt; Task &lt;span class=&quot;hljs-title&quot;&gt;Invoke&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;HttpContext context&lt;/span&gt;)
    &lt;/span&gt;{
        _logger.Log(&lt;span class=&quot;hljs-string&quot;&gt;&quot;Handling request&quot;&lt;/span&gt;);
        &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; _next(context); &lt;span class=&quot;hljs-comment&quot;&gt;// Call the next middleware in the pipeline&lt;/span&gt;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To use the middleware in your app, add it to the middleware pipeline in &lt;code&gt;Program.cs&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;app.UseMiddleware&amp;lt;RequestLoggingMiddleware&amp;gt;()&lt;span class=&quot;hljs-comment&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;3-constructor-injection-vs-method-injection-&quot;&gt;3. &lt;strong&gt;Constructor Injection vs Method Injection&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Constructor injection is the most common form of Dependency Injection, but there are other options, such as &lt;strong&gt;method injection&lt;/strong&gt; and &lt;strong&gt;property injection&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Constructor Injection&lt;/strong&gt;: Dependencies are injected via the constructor, which is the preferred and most widely used approach.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Method Injection&lt;/strong&gt;: Dependencies are passed to a specific method when they are needed, offering more flexibility.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-function&quot;&gt;IActionResult &lt;span class=&quot;hljs-title&quot;&gt;Index&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;([FromServices] ILoggerService logger)&lt;/span&gt;
&lt;/span&gt;{
    logger.Log(&lt;span class=&quot;hljs-string&quot;&gt;&quot;Handling Index action&quot;&lt;/span&gt;);
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;()&lt;/span&gt;&lt;/span&gt;;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, the &lt;code&gt;ILoggerService&lt;/code&gt; is injected directly into the &lt;code&gt;Index&lt;/code&gt; action method using &lt;code&gt;[FromServices]&lt;/code&gt;, which allows you to inject services only when needed.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;4-scoped-services-in-middleware-&quot;&gt;4. &lt;strong&gt;Scoped Services in Middleware&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;If you’re using &lt;strong&gt;scoped services&lt;/strong&gt; (services that are created once per request), injecting them into middleware requires special handling because middleware components are typically singleton services. To use scoped services in middleware, you can request a scope from the &lt;code&gt;IServiceProvider&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;ScopedMiddleware&lt;/span&gt;
{
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;readonly&lt;/span&gt; RequestDelegate _next;

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;ScopedMiddleware&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;RequestDelegate next&lt;/span&gt;)
    &lt;/span&gt;{
        _next = next;
    }

    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt; Task &lt;span class=&quot;hljs-title&quot;&gt;Invoke&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;HttpContext context, IServiceProvider serviceProvider&lt;/span&gt;)
    &lt;/span&gt;{
        &lt;span class=&quot;hljs-keyword&quot;&gt;using&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; scope = serviceProvider.CreateScope())
        {
            &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; scopedService = scope.ServiceProvider.GetRequiredService&amp;lt;IMyScopedService&amp;gt;();
            &lt;span class=&quot;hljs-comment&quot;&gt;// Use the scoped service here&lt;/span&gt;
        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; _next(context);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;testing-with-dependency-injection&quot;&gt;Testing with Dependency Injection&lt;/h2&gt;
&lt;p&gt;One of the major advantages of Dependency Injection is that it makes unit testing much easier. Since dependencies are injected into your classes, you can easily mock them during testing.&lt;/p&gt;
&lt;p&gt;Here’s an example of unit testing a controller that uses DI:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;HomeControllerTests&lt;/span&gt;
{
    [Fact]
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Index_ShouldLogMessage&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;)
    &lt;/span&gt;{
        &lt;span class=&quot;hljs-comment&quot;&gt;// Arrange&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; mockLogger = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; Mock&amp;lt;ILoggerService&amp;gt;();
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; controller = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; HomeController(mockLogger.Object);

        &lt;span class=&quot;hljs-comment&quot;&gt;// Act&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; result = controller.Index();

        &lt;span class=&quot;hljs-comment&quot;&gt;// Assert&lt;/span&gt;
        mockLogger.Verify(l =&amp;gt; l.Log(&lt;span class=&quot;hljs-string&quot;&gt;&quot;Handling Index action&quot;&lt;/span&gt;), Times.Once);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By using a mocking framework like &lt;strong&gt;Moq&lt;/strong&gt;, you can mock the behavior of the &lt;code&gt;ILoggerService&lt;/code&gt; and verify that the &lt;code&gt;Log&lt;/code&gt; method is called when the &lt;code&gt;Index&lt;/code&gt; action is invoked.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Dependency Injection is a fundamental design pattern in .NET 6 that enables developers to write more modular, testable, and maintainable code. By mastering DI, you can&lt;/p&gt;
&lt;p&gt; build applications that are easier to scale, adapt, and debug.&lt;/p&gt;
&lt;p&gt;From basic service registration to advanced techniques like injecting multiple implementations or using scoped services in middleware, .NET 6 provides a robust and flexible DI framework that meets the needs of modern web development. Understanding and applying DI principles effectively will significantly improve the architecture and quality of your applications.&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/8278352419033005621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/mastering-dependency-injection-in-net-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/8278352419033005621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/8278352419033005621'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/mastering-dependency-injection-in-net-6.html' title='Mastering Dependency Injection in .NET 6'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMK4eGEKvotQGw_dzmqV64oJimrmnhEukCOw-y7px2Ih-lqBX3l58VSaLO2Y-vEajP5HmmMXESbsZkaie2EEDJyushbstjfYpS4Q1XDfyuIipeTQWM21NuFBIIOfAwRwTtpdn5IC3sNSLYrSsU_gdaxs96n4wLpYuj8XQKqP0F4xprDGNxwQ2M6kOyYvbH/s72-w640-h480-c/coding-computer-data-depth-of-field-577585.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-1199460076504186472</id><published>2024-10-16T12:59:00.008+05:30</published><updated>2024-10-16T13:11:28.998+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 6"/><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="DevOps"/><title type='text'>How to Set Up Azure DevOps Pipelines for .NET 6 Projects</title><content type='html'>    &lt;p&gt;Continuous Integration (CI) and Continuous Deployment (CD) are becoming increasingly crucial for delivering high-quality software quickly and efficiently in today&#39;s jet age development era. &lt;strong&gt;Azure DevOps&lt;/strong&gt; provides a comprehensive suite of tools that facilitate CI/CD for various types of projects, including &lt;strong&gt;.NET 6&lt;/strong&gt; applications. This article will guide you through setting up Azure DevOps pipelines to automate the build, test, and deployment processes for your .NET 6 projects.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;

    &lt;h2&gt;Why Use Azure DevOps for .NET 6 Projects?&lt;/h2&gt;

    &lt;p&gt;Azure DevOps offers a robust set of features tailored for modern software development:&lt;/p&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;strong&gt;Integrated Tools&lt;/strong&gt;: Azure DevOps provides everything from version control to project management, build automation, and deployment in one place  .&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Support for Multiple Languages and Platforms&lt;/strong&gt;: While it excels with .NET applications, Azure DevOps supports various programming languages and platforms .&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: Azure DevOps can accommodate projects of any size, from small startups to large enterprises .&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Rich Ecosystem&lt;/strong&gt;: Integrate with popular tools like GitHub, Slack, and more for a seamless workflow .&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h2&gt;Prerequisites&lt;/h2&gt;

    &lt;p&gt;Before setting up Azure DevOps pipelines for your .NET 6 projects, ensure you have the following:&lt;/p&gt;
    &lt;ol&gt;
        &lt;li&gt;&lt;strong&gt;Azure DevOps Account&lt;/strong&gt;: If you don&#39;t already have one, sign up for a free Azure DevOps account at &lt;a href=&quot;https://dev.azure.com&quot;&gt;dev.azure.com&lt;/a&gt;.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;.NET 6 SDK&lt;/strong&gt;: Ensure the .NET 6 SDK is installed locally. You can download it from the &lt;a href=&quot;https://dotnet.microsoft.com/download/dotnet/6.0&quot;&gt;official .NET website&lt;/a&gt;.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Source Code Repository&lt;/strong&gt;: Your .NET 6 project should be stored in a source code repository, such as Azure Repos or GitHub .&lt;/li&gt;
    &lt;/ol&gt;

    &lt;h2&gt;Step 1: Create a New Azure DevOps Project&lt;/h2&gt;

    &lt;ol&gt;
        &lt;li&gt;&lt;strong&gt;Log in to Azure DevOps&lt;/strong&gt;: Go to &lt;a href=&quot;https://dev.azure.com&quot;&gt;dev.azure.com&lt;/a&gt; and log in to your account.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Create a New Project&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on &lt;strong&gt;New Project&lt;/strong&gt;.&lt;/li&gt;
                &lt;li&gt;Enter your project name, description, and visibility (private or public).&lt;/li&gt;
                &lt;li&gt;Click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ol&gt;

    &lt;h2&gt;Step 2: Set Up Your Repository&lt;/h2&gt;

    &lt;p&gt;If your .NET 6 project is not already in Azure Repos or GitHub, you can import your code:&lt;/p&gt;

    &lt;ol&gt;
        &lt;li&gt;&lt;strong&gt;Navigate to Repos&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;In your Azure DevOps project, click on &lt;strong&gt;Repos&lt;/strong&gt; from the left sidebar.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Import Repository&lt;/strong&gt;:
            &lt;/li&gt;&lt;ul&gt;
                &lt;li&gt;If you&#39;re using Azure Repos, you can directly create a new repository and push your code.&lt;/li&gt;
                &lt;li&gt;If using GitHub, you can connect your GitHub account to Azure DevOps and select the repository.&lt;/li&gt;
            &lt;/ul&gt;
        
    &lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjo3pJbcT-0vuPfqy-C9ajCkxVXcEB_pwFgp53C-ggZrBiZ5_4WGWgeJsEqhb5PVhjGtiHaMPKW6Cbc-zNGR92A8FqTqfDYkbomF9aEmAovCbTb24UmOQvcvqLOoVZyQyJ_pbFdGQE0gaaa1PnKxfCleMe4DrEy9Kkww-b5RtZyzxKqdlosHUBGBymj7Td/s2700/pexels-pixabay-372796.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2025&quot; data-original-width=&quot;2700&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjo3pJbcT-0vuPfqy-C9ajCkxVXcEB_pwFgp53C-ggZrBiZ5_4WGWgeJsEqhb5PVhjGtiHaMPKW6Cbc-zNGR92A8FqTqfDYkbomF9aEmAovCbTb24UmOQvcvqLOoVZyQyJ_pbFdGQE0gaaa1PnKxfCleMe4DrEy9Kkww-b5RtZyzxKqdlosHUBGBymj7Td/w640-h480/pexels-pixabay-372796.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

    &lt;h2&gt;Step 3: Create a Build Pipeline&lt;/h2&gt;

    &lt;p&gt;A build pipeline automates the process of compiling your code, running tests, and creating artifacts.&lt;/p&gt;

    &lt;ol&gt;
        &lt;li&gt;&lt;strong&gt;Go to Pipelines&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;In your Azure DevOps project, click on &lt;strong&gt;Pipelines&lt;/strong&gt; from the left sidebar.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Create Pipeline&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on &lt;strong&gt;New Pipeline&lt;/strong&gt;.&lt;/li&gt;
                &lt;li&gt;Choose the source where your code is stored (e.g., Azure Repos or GitHub).&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Select a Template&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Azure DevOps provides various templates. For .NET 6 projects, choose &lt;strong&gt;ASP.NET Core&lt;/strong&gt;.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Configure Your Pipeline&lt;/strong&gt;:
            &lt;p&gt;The YAML file that defines your pipeline will open in the editor. By default, it might look something like this:&lt;/p&gt;
            &lt;pre&gt;&lt;code&gt;trigger:
  branches:
    include:
      - main

pool:
  vmImage: &#39;windows-latest&#39;

steps:
  - task: UseDotNet@2
    inputs:
      packageType: &#39;sdk&#39;
      version: &#39;6.x&#39;
      installationPath: $(Agent.ToolsDirectory)/dotnet

  - script: dotnet build --configuration Release
    displayName: &#39;Build Project&#39;

  - script: dotnet test --no-restore --verbosity normal
    displayName: &#39;Run Tests&#39;

  - task: PublishBuildArtifacts@1
    inputs:
      PathtoPublish: &#39;$(Build.ArtifactStagingDirectory)&#39;
      ArtifactName: &#39;drop&#39;
      publishLocation: &#39;Container&#39;&lt;/code&gt;&lt;/pre&gt;
            &lt;p&gt;This YAML file does the following:&lt;/p&gt;
            &lt;ul&gt;
                &lt;li&gt;Triggers the pipeline on changes to the &lt;code&gt;main&lt;/code&gt; branch.&lt;/li&gt;
                &lt;li&gt;Uses a Windows virtual machine image.&lt;/li&gt;
                &lt;li&gt;Installs the .NET 6 SDK.&lt;/li&gt;
                &lt;li&gt;Builds the project in Release mode.&lt;/li&gt;
                &lt;li&gt;Runs the tests.&lt;/li&gt;
                &lt;li&gt;Publishes the build artifacts.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Save and Run&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click &lt;strong&gt;Save and run&lt;/strong&gt;. This will trigger the pipeline for the first time, allowing you to monitor the build process.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ol&gt;

    &lt;h2&gt;Step 4: Create a Release Pipeline&lt;/h2&gt;

    &lt;p&gt;Once your build pipeline is set up, the next step is to create a release pipeline that deploys your application.&lt;/p&gt;

    &lt;ol&gt;
        &lt;li&gt;&lt;strong&gt;Go to Releases&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on &lt;strong&gt;Pipelines&lt;/strong&gt; in the left sidebar, then select &lt;strong&gt;Releases&lt;/strong&gt;.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Create Release Pipeline&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on &lt;strong&gt;New&lt;/strong&gt; and select &lt;strong&gt;New Release Pipeline&lt;/strong&gt;.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Select a Template&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Choose the &lt;strong&gt;Empty Job&lt;/strong&gt; template.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Add Artifact&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on &lt;strong&gt;Add an artifact&lt;/strong&gt; and select the build pipeline you created earlier. This connects the release pipeline to the artifacts produced by the build.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Add Stages&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on the &lt;strong&gt;+&lt;/strong&gt; to add a stage (e.g., Development, Staging, Production).&lt;/li&gt;
                &lt;li&gt;In the stage, click on &lt;strong&gt;Tasks&lt;/strong&gt; to configure deployment steps.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ol&gt;

    &lt;h3&gt;Example: Deploying to Azure App Service&lt;/h3&gt;

    &lt;p&gt;If you&#39;re deploying to Azure App Service, follow these steps:&lt;/p&gt;

    &lt;ol&gt;
        &lt;li&gt;&lt;strong&gt;Add Azure App Service Deploy Task&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on the &lt;strong&gt;+&lt;/strong&gt; icon in your stage, search for &lt;strong&gt;Azure App Service Deploy&lt;/strong&gt;, and add it.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Configure the Task&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Choose your Azure subscription andHere&#39;s the continuation and completion of the HTML translation for the article **&quot;How to Set Up Azure DevOps Pipelines for .NET 6 Projects&quot;** with sources and citations provided in footnotes:

```html
                &lt;/li&gt;&lt;li&gt;App Service name.&lt;/li&gt;
                &lt;li&gt;Select the package or folder to deploy (use the artifact published from the build pipeline).&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Save and Create Release&lt;/strong&gt;:
            &lt;ul&gt;
                &lt;li&gt;Click on &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
                &lt;li&gt;Click on &lt;strong&gt;Create Release&lt;/strong&gt;, choose the artifact version, and deploy.&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ol&gt;

    &lt;h2&gt;Step 5: Monitor Your Pipelines&lt;/h2&gt;

    &lt;p&gt;Once your pipelines are set up and running, you can monitor their progress:&lt;/p&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;strong&gt;Build Pipeline&lt;/strong&gt;: Click on &lt;strong&gt;Pipelines&lt;/strong&gt; to see the status of your builds. You can view logs and details for each build.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Release Pipeline&lt;/strong&gt;: Click on &lt;strong&gt;Releases&lt;/strong&gt; to track the status of your deployments. View logs for each stage to ensure everything is working as expected.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h2&gt;Conclusion&lt;/h2&gt;
    &lt;p&gt;Setting up Azure DevOps pipelines for your .NET 6 projects automates the build and deployment process, helping you deliver high-quality software faster and more efficiently. With Azure DevOps, you can leverage powerful CI/CD tools to streamline your development workflow.&lt;/p&gt;

    &lt;p&gt;By following the steps outlined in this article, you can confidently set up your Azure DevOps pipelines and take full advantage of the benefits that come with Continuous Integration and Continuous Deployment. Start your journey towards more efficient software development with Azure DevOps today!&lt;/p&gt;

    &lt;footer&gt;
        &lt;p&gt;Footnotes:&lt;/p&gt;
        &lt;ol&gt;
            &lt;li&gt;For more information on Azure DevOps, visit the official documentation at &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/devops/?view=azure-devops&quot;&gt;Azure DevOps Documentation&lt;/a&gt;.&lt;/li&gt;
            &lt;li&gt;To learn about .NET 6, check out the official .NET website at &lt;a href=&quot;https://dotnet.microsoft.com/download/dotnet/6.0&quot;&gt;.NET 6 Download&lt;/a&gt;.&lt;/li&gt;
            &lt;li&gt;For details on CI/CD practices, refer to &lt;a href=&quot;https://www.atlassian.com/continuous-delivery/ci-vs-ci&quot;&gt;Atlassian&#39;s CI/CD Guide&lt;/a&gt;.&lt;/li&gt;
            &lt;li&gt;For insights on setting up pipelines, see &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops&quot;&gt;Pipelines in Azure DevOps&lt;/a&gt;.&lt;/li&gt;
        &lt;/ol&gt;
    &lt;/footer&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/1199460076504186472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-set-up-azure-devops-pipelines.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/1199460076504186472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/1199460076504186472'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-set-up-azure-devops-pipelines.html' title='How to Set Up Azure DevOps Pipelines for .NET 6 Projects'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjo3pJbcT-0vuPfqy-C9ajCkxVXcEB_pwFgp53C-ggZrBiZ5_4WGWgeJsEqhb5PVhjGtiHaMPKW6Cbc-zNGR92A8FqTqfDYkbomF9aEmAovCbTb24UmOQvcvqLOoVZyQyJ_pbFdGQE0gaaa1PnKxfCleMe4DrEy9Kkww-b5RtZyzxKqdlosHUBGBymj7Td/s72-w640-h480-c/pexels-pixabay-372796.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-318943909260384775</id><published>2024-10-15T09:49:00.003+05:30</published><updated>2024-10-15T09:50:06.188+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 6"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><title type='text'>Getting Started with ASP.NET Core 6 for Web Development</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;Web development has evolved drastically over the years, with new frameworks and technologies continuously pushing the boundaries of what’s possible. At the forefront of these advancements is &lt;strong&gt;ASP.NET Core 6&lt;/strong&gt;, a powerful, cross-platform framework that allows developers to build high-performance, scalable web applications using the latest features of .NET.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this guide, we’ll take you through the fundamentals of &lt;strong&gt;ASP.NET Core 6&lt;/strong&gt;, from setting up your development environment to creating your first web application. Whether you&#39;re an experienced developer or someone new to ASP.NET Core, this guide will help you hit the ground running.&lt;/p&gt;

&lt;h2&gt;Why Choose ASP.NET Core 6?&lt;/h2&gt;
&lt;p&gt;ASP.NET Core 6 is part of the &lt;strong&gt;.NET 6&lt;/strong&gt; ecosystem, which is the latest long-term support (LTS) release from Microsoft. It builds upon the foundation of earlier versions of ASP.NET Core, introducing a host of new features designed to simplify web development while improving performance.&lt;/p&gt;

&lt;h3&gt;Key Benefits of ASP.NET Core 6:&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Cross-Platform&lt;/strong&gt;: ASP.NET Core 6 allows you to develop and deploy web applications on Windows, macOS, and Linux.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;High Performance&lt;/strong&gt;: ASP.NET Core is known for its blazing-fast performance, making it an ideal choice for building scalable, high-traffic web applications.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Unified .NET Platform&lt;/strong&gt;: With the release of .NET 6, ASP.NET Core 6 benefits from a unified platform, enabling you to build web, desktop, mobile, cloud, and IoT apps using a single framework.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Minimal APIs&lt;/strong&gt;: ASP.NET Core 6 introduces Minimal APIs, which allows developers to build lightweight APIs with less boilerplate code.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Built-in Dependency Injection&lt;/strong&gt;: ASP.NET Core has a powerful built-in dependency injection system that makes your code modular and testable.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Secure by Default&lt;/strong&gt;: With features like HTTPS by default, data protection, and identity management, ASP.NET Core 6 provides robust security out of the box.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we’ve covered why ASP.NET Core 6 is an excellent choice, let’s dive into how you can start building web applications with it.&lt;/p&gt;

&lt;h2&gt;Setting Up Your Development Environment&lt;/h2&gt;
&lt;p&gt;Before you start building your first web application, you’ll need to set up your development environment.&lt;/p&gt;

&lt;h3&gt;Step 1: Install .NET 6 SDK&lt;/h3&gt;
&lt;p&gt;First, you need to install the &lt;strong&gt;.NET 6 SDK&lt;/strong&gt;, which includes everything you need to develop and run .NET 6 applications, including ASP.NET Core 6.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Head over to the &lt;a href=&quot;https://dotnet.microsoft.com/download/dotnet/6.0&quot; target=&quot;_blank&quot;&gt;official .NET website&lt;/a&gt; and download the appropriate SDK for your operating system (Windows, macOS, or Linux).&lt;/li&gt;
	&lt;li&gt;After downloading, run the installer and follow the setup instructions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Step 2: Install Visual Studio 2022&lt;/h3&gt;
&lt;p&gt;To get the most out of ASP.NET Core 6, you’ll need an integrated development environment (IDE). &lt;strong&gt;Visual Studio 2022&lt;/strong&gt; is the recommended IDE for .NET development, offering a seamless development experience with built-in tools for debugging, testing, and deployment.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;You can download Visual Studio 2022 from the &lt;a href=&quot;https://visualstudio.microsoft.com/downloads/&quot; target=&quot;_blank&quot;&gt;Visual Studio website&lt;/a&gt;.&lt;/li&gt;
	&lt;li&gt;During installation, make sure to select the &lt;strong&gt;ASP.NET and web development&lt;/strong&gt; workload.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Alternatively, if you prefer a lightweight editor, you can use &lt;strong&gt;Visual Studio Code&lt;/strong&gt; with the necessary .NET extensions.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7S8bE8NjSN2iWi9ZJF8FIC-SJ6O6mVUzZmo053KGduSdqPidpot8mp5myQmi3B4aSiws2YGwjvval99yTt0WkEolQAJGpzsyZb8nGkb484gOKna6K7h1yF2NJWUPtyfssvBMzP_j4WGJAWSatcRFNUlFMwUAnQ_kjCe5_7wL6TVWMVzmolJ7qDKDK4sA9/s1280/laptop-office-internet-technology-177598.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7S8bE8NjSN2iWi9ZJF8FIC-SJ6O6mVUzZmo053KGduSdqPidpot8mp5myQmi3B4aSiws2YGwjvval99yTt0WkEolQAJGpzsyZb8nGkb484gOKna6K7h1yF2NJWUPtyfssvBMzP_j4WGJAWSatcRFNUlFMwUAnQ_kjCe5_7wL6TVWMVzmolJ7qDKDK4sA9/w640-h426/laptop-office-internet-technology-177598.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Creating Your First ASP.NET Core 6 Web Application&lt;/h2&gt;
&lt;p&gt;Once your environment is set up, you can start creating your first ASP.NET Core 6 web application.&lt;/p&gt;

&lt;h3&gt;Step 1: Create a New ASP.NET Core Project&lt;/h3&gt;
&lt;p&gt;To create a new ASP.NET Core 6 project in Visual Studio 2022:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Open Visual Studio and select &lt;strong&gt;Create a new project&lt;/strong&gt;.&lt;/li&gt;
	&lt;li&gt;In the &lt;strong&gt;Create a new project&lt;/strong&gt; window, search for &lt;strong&gt;ASP.NET Core Web Application&lt;/strong&gt; and select it.&lt;/li&gt;
	&lt;li&gt;Name your project (e.g., &quot;MyFirstAspNetApp&quot;), choose a location, and click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
	&lt;li&gt;In the &lt;strong&gt;Create a new ASP.NET Core Web Application&lt;/strong&gt; window, select &lt;strong&gt;ASP.NET Core 6.0 (Long-term support)&lt;/strong&gt; as the target framework.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can choose to create either a &lt;strong&gt;Web Application (Model-View-Controller)&lt;/strong&gt;, &lt;strong&gt;Razor Pages&lt;/strong&gt;, or an &lt;strong&gt;Empty&lt;/strong&gt; project, depending on your needs. For this tutorial, let’s go with the &lt;strong&gt;Web Application (Model-View-Controller)&lt;/strong&gt; template.&lt;/p&gt;

&lt;h3&gt;Step 2: Explore the Project Structure&lt;/h3&gt;
&lt;p&gt;Once the project is created, you’ll notice several folders and files. Here’s a brief overview of the key components:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Controllers&lt;/strong&gt;: This folder contains your MVC controllers. Controllers handle incoming HTTP requests and return the appropriate response, usually by rendering views or returning data as JSON.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Views&lt;/strong&gt;: This folder contains the Razor views, which are used to generate HTML for the web pages that your application serves. Razor syntax allows you to mix C# with HTML for dynamic content rendering.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;wwwroot&lt;/strong&gt;: This is the root folder for static files like CSS, JavaScript, and images.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;appsettings.json&lt;/strong&gt;: A configuration file used to store settings such as database connection strings, logging settings, and other app-specific configuration.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Program.cs&lt;/strong&gt; and &lt;strong&gt;Startup.cs&lt;/strong&gt;: In ASP.NET Core 6, the startup configuration is simplified by merging `Startup.cs` into `Program.cs`. This is where you configure the services, middleware, and the HTTP request pipeline.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Step 3: Understanding the Minimal APIs Approach&lt;/h3&gt;
&lt;p&gt;One of the most exciting new features of ASP.NET Core 6 is the &lt;strong&gt;Minimal APIs&lt;/strong&gt; feature, which allows developers to quickly create small APIs with minimal configuration.&lt;/p&gt;
&lt;pre&gt;	&lt;code&gt;
		var builder = WebApplication.CreateBuilder(args);
		var app = builder.Build();

		app.MapGet(&quot;/&quot;, () =&amp;gt; &quot;Hello World!&quot;);

		app.Run();
	&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;This is a simple API that responds with &quot;Hello World!&quot; when the root URL is accessed. Minimal APIs are perfect for building small, focused web services without the overhead of a full MVC structure.&lt;/p&gt;

&lt;h3&gt;Step 4: Run Your Application&lt;/h3&gt;
&lt;p&gt;Once you’ve created your project, you can run the application by pressing &lt;strong&gt;F5&lt;/strong&gt; in Visual Studio or by selecting &lt;strong&gt;Debug &amp;gt; Start Debugging&lt;/strong&gt; from the menu. This will launch the application in your default browser, and you should see the default home page of your ASP.NET Core application.&lt;/p&gt;
&lt;p&gt;Congratulations, you’ve just created and run your first ASP.NET Core 6 web application!&lt;/p&gt;

&lt;h2&gt;Adding a Controller and View&lt;/h2&gt;
&lt;p&gt;Let’s add some functionality to your app by creating a new controller and view.&lt;/p&gt;

&lt;h3&gt;Step 1: Add a Controller&lt;/h3&gt;
&lt;p&gt;Right-click on the &lt;strong&gt;Controllers&lt;/strong&gt; folder, select &lt;strong&gt;Add &amp;gt; Controller&lt;/strong&gt;, and choose &lt;strong&gt;MVC Controller – Empty&lt;/strong&gt;. Name the controller &lt;strong&gt;HelloController&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In `HelloController.cs`, add the following code:&lt;/p&gt;
&lt;pre&gt;	&lt;code&gt;
		public class HelloController : Controller
		{
			public IActionResult Index()
			{
				return View();
			}
		}
	&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;This controller contains an `Index` action that will return a view.&lt;/p&gt;

&lt;h3&gt;Step 2: Add a View&lt;/h3&gt;
&lt;p&gt;Now, right-click on the &lt;strong&gt;Views&lt;/strong&gt; folder, select &lt;strong&gt;Add &amp;gt; New Folder&lt;/strong&gt;, and name the folder &lt;strong&gt;Hello&lt;/strong&gt;. Right-click on the new &lt;strong&gt;Hello&lt;/strong&gt; folder, select &lt;strong&gt;Add &amp;gt; New Item&lt;/strong&gt;, and choose &lt;strong&gt;Razor View&lt;/strong&gt;. Name the view &lt;strong&gt;Index.cshtml&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In `Index.cshtml`, add the following code:&lt;/p&gt;
&lt;pre&gt;	&lt;code&gt;
		&amp;lt;h1&amp;gt;Hello from ASP.NET Core!&amp;lt;/h1&amp;gt;
	&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Run the application again, navigate to `/Hello`, and you should see your new view.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;ASP.NET Core 6 brings exciting new features to the table, making it easier than ever to build high-performance web applications. From Minimal APIs to enhanced performance, there’s a lot to love about this framework. We hope this guide has helped you get started with ASP.NET Core 6. Stay tuned for more advanced topics in future posts!&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/318943909260384775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/getting-started-with-aspnet-core-6-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/318943909260384775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/318943909260384775'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/getting-started-with-aspnet-core-6-for.html' title='Getting Started with ASP.NET Core 6 for Web Development'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7S8bE8NjSN2iWi9ZJF8FIC-SJ6O6mVUzZmo053KGduSdqPidpot8mp5myQmi3B4aSiws2YGwjvval99yTt0WkEolQAJGpzsyZb8nGkb484gOKna6K7h1yF2NJWUPtyfssvBMzP_j4WGJAWSatcRFNUlFMwUAnQ_kjCe5_7wL6TVWMVzmolJ7qDKDK4sA9/s72-w640-h426-c/laptop-office-internet-technology-177598.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-7412061489956496537</id><published>2024-10-14T19:11:00.004+05:30</published><updated>2024-10-14T19:25:14.775+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 6"/><category scheme="http://www.blogger.com/atom/ns#" term="Blazor"/><title type='text'>Boosting Performance with .NET 6 and Blazor</title><content type='html'>&lt;p&gt;Let&#39;s face it, application performance can virtually make or break the user experience in today&#39;s digital world. If your app is slow, users leave, conversions drop, and your brand image suffers. Enter .NET 6 and Blazor, the duo that&#39;s transforming how developers build fast, scalable, and high-performance web applications.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;.NET 6, Microsoft&#39;s latest long-term support (LTS) release, is packed with features that enhance performance, improve developer productivity, and make it easier to build modern web apps. Paired with Blazor, a framework that allows developers to build interactive web applications using C# and .NET, it opens the door to blazing fast, client-side experiences. Let’s dive into how you can boost the performance of your web applications using .NET 6 and Blazor.&lt;/p&gt;

&lt;h2&gt;Understanding Blazor and Its Performance Boosts in .NET 6&lt;/h2&gt;
&lt;p&gt;Blazor is part of the ASP.NET Core framework and enables developers to write rich web UIs using C# instead of JavaScript. Blazor comes in two flavors: &lt;strong&gt;Blazor Server&lt;/strong&gt; and &lt;strong&gt;Blazor WebAssembly (WASM)&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Blazor Server:&lt;/strong&gt; Runs on the server, sending UI updates to the browser over a SignalR connection.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Blazor WebAssembly:&lt;/strong&gt; Runs directly in the browser on WebAssembly, allowing full client-side interactivity without the need for JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With .NET 6, both Blazor versions have received significant performance enhancements, making it a perfect choice for building fast, responsive web apps.&lt;/p&gt;

&lt;h3&gt;1. Enhanced Ahead-of-Time (AOT) Compilation for Blazor WASM&lt;/h3&gt;
&lt;p&gt;One of the biggest upgrades in .NET 6 for Blazor WebAssembly is the introduction of &lt;strong&gt;Ahead-of-Time (AOT) Compilation&lt;/strong&gt;. In .NET 5, Blazor WebAssembly relied solely on Just-In-Time (JIT) compilation, which meant the app&#39;s code was compiled on the client side after being downloaded. This approach could slow down initial load times.&lt;/p&gt;

&lt;p&gt;In .NET 6, AOT compilation allows you to compile your Blazor app directly to WebAssembly before it&#39;s even shipped to the client. This means the browser no longer needs to compile the app, drastically improving load times and runtime performance.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;PropertyGroup&amp;gt;
&amp;lt;BlazorWebAssemblyEnableCompression&amp;gt;true&amp;lt;/BlazorWebAssemblyEnableCompression&amp;gt;
&amp;lt;RunAOTCompilation&amp;gt;true&amp;lt;/RunAOTCompilation&amp;gt;
&amp;lt;/PropertyGroup&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By using AOT, your Blazor WebAssembly app will feel snappier, with quicker interactions and faster load times, especially for users on slower devices or networks.&lt;/p&gt;

&lt;h3&gt;2. Reducing Payload Sizes with Lazy Loading&lt;/h3&gt;
&lt;p&gt;Large applications can suffer from bloated payloads—long initial load times as the entire app is downloaded upfront. But with .NET 6, &lt;strong&gt;lazy loading of assemblies&lt;/strong&gt; has been introduced to address this issue. Lazy loading allows parts of your Blazor WebAssembly app to be loaded only when they are needed, reducing the upfront payload size and improving the app’s perceived performance.&lt;/p&gt;

&lt;p&gt;Here&#39;s a quick example of how you can implement lazy loading for specific assemblies in your Blazor WebAssembly app:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@if (assemblyIsLoaded)
{
&amp;lt;YourComponent /&amp;gt;
}
else
{
&amp;lt;button @onclick=&quot;LoadAssembly&quot;&amp;gt;Load Feature&amp;lt;/button&amp;gt;
}

@code {
private bool assemblyIsLoaded = false;

private async Task LoadAssembly()
{
	await LazyLoader.LoadAssembliesAsync(new[] { &quot;YourAssembly.dll&quot; });
	assemblyIsLoaded = true;
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By only loading what the user needs when they need it, you keep the initial download light and fast, improving the overall user experience.&lt;/p&gt;

&lt;h3&gt;3. Prerendering with Blazor WASM for Instant Feedback&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Prerendering&lt;/strong&gt; is another feature in .NET 6 that can give your Blazor apps a performance edge. With prerendering, the first load of your Blazor WebAssembly app can be processed on the server, providing immediate content to the user while the Blazor WebAssembly app is downloading in the background.&lt;/p&gt;

&lt;p&gt;This eliminates the delay where users would normally see a blank page while the WebAssembly payload is being fetched. You can implement prerendering in Blazor using a combination of &lt;strong&gt;Blazor WebAssembly&lt;/strong&gt; and &lt;strong&gt;Blazor Server&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;1. &lt;strong&gt;Configure your &lt;code&gt;Program.cs&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;builder.Services.AddRazorComponents();
builder.RootComponents.Add&amp;lt;App&amp;gt;(&quot;#app&quot;, RenderMode.ServerPrerendered);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;2. &lt;strong&gt;Ensure your component layout can switch from server prerendering to client-side WebAssembly mode&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This technique provides a nearly instant response to users while the full app continues to load, creating a more seamless user experience.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrwvJ7TFRh-XmpWUTWRepIgz35u8_1K_aN0s52bKKdHhjlnEiauUe4OOv41p67beHMc90FVqIalKRhnONrX8WQth-1XRqn3Aefo5-rRyW3CCB4hbBOdoLJ3Wo3HVxMa2c0kE8gC3Idz7fpuKEWxV2mAOhTeRD2b8078driLjD7uoVE_nWT49LjEngEVuhZ/s1280/internet-technology-computer-display-1089440.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrwvJ7TFRh-XmpWUTWRepIgz35u8_1K_aN0s52bKKdHhjlnEiauUe4OOv41p67beHMc90FVqIalKRhnONrX8WQth-1XRqn3Aefo5-rRyW3CCB4hbBOdoLJ3Wo3HVxMa2c0kE8gC3Idz7fpuKEWxV2mAOhTeRD2b8078driLjD7uoVE_nWT49LjEngEVuhZ/w640-h426/internet-technology-computer-display-1089440.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3&gt;4. Leveraging .NET 6 Hot Reload for Faster Development&lt;/h3&gt;
&lt;p&gt;Although not directly tied to production performance, the &lt;strong&gt;Hot Reload&lt;/strong&gt; feature in .NET 6 allows developers to make code changes while the app is running without having to restart the app. This speeds up development cycles and allows you to iterate faster, ensuring your performance optimizations can be tested and implemented more efficiently.&lt;/p&gt;

&lt;p&gt;You can enable Hot Reload by simply running your Blazor project with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;dotnet watch run
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you make changes, Hot Reload automatically applies those changes without restarting the entire app, reducing downtime during development.&lt;/p&gt;

&lt;h3&gt;5. SignalR Performance Enhancements in Blazor Server&lt;/h3&gt;
&lt;p&gt;For Blazor Server applications, &lt;strong&gt;SignalR&lt;/strong&gt; plays a crucial role in maintaining the connection between the client and the server. In .NET 6, SignalR has been optimized to improve connection stability and message dispatch performance, reducing latency and ensuring faster communication between the server and the client.&lt;/p&gt;

&lt;p&gt;Additionally, SignalR in .NET 6 supports &lt;strong&gt;Azure SignalR Service&lt;/strong&gt;, which allows for scaling out SignalR connections in the cloud, further boosting performance in large-scale applications.&lt;/p&gt;

&lt;h3&gt;6. Optimized JavaScript Interoperability (JS Interop)&lt;/h3&gt;
&lt;p&gt;While Blazor lets you write C# for almost everything, you might still need to call JavaScript occasionally for specialized functionality. In .NET 6, &lt;strong&gt;JS Interop&lt;/strong&gt; has been optimized for faster communication between C# and JavaScript. This improvement reduces the overhead involved in making JS calls, which can sometimes slow down your application, particularly when making frequent or heavy JS Interop calls.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[Inject] IJSRuntime JsRuntime { get; set; }

protected async Task TriggerJavaScriptAlert()
{
await JsRuntime.InvokeVoidAsync(&quot;alert&quot;, &quot;Hello from Blazor!&quot;);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The optimized JS Interop in .NET 6 ensures that these calls are handled more efficiently, minimizing performance bottlenecks.&lt;/p&gt;

&lt;h3&gt;7. Blazor WebAssembly and Web Workers&lt;/h3&gt;
&lt;p&gt;If your Blazor WebAssembly app needs to perform resource-heavy operations (such as image processing or data analysis), consider using &lt;strong&gt;Web Workers&lt;/strong&gt;. Web Workers allow you to offload computationally expensive tasks to a separate background thread, freeing up the main UI thread and keeping the application responsive.&lt;/p&gt;

&lt;p&gt;In .NET 6, you can integrate Web Workers by leveraging JavaScript Web APIs and Blazor&#39;s JS Interop. This can greatly improve your app’s performance, especially for CPU-bound tasks.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;.NET 6 and Blazor have come a long way in delivering high-performance web applications. Whether you&#39;re using Blazor WebAssembly for full client-side experiences or Blazor Server for real-time, server-side rendering, the enhancements in .NET 6—from AOT compilation to lazy loading—empower developers to build fast, modern, and scalable web apps.&lt;/p&gt;

&lt;p&gt;By combining these techniques, you can dramatically improve the performance of your Blazor apps, offering users a seamless and snappy experience. Remember, in the web world, speed matters—a lot. Take advantage of these features to keep your users engaged, happy, and coming back for more!&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/7412061489956496537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/boosting-performance-with-net-6-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/7412061489956496537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/7412061489956496537'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/boosting-performance-with-net-6-and.html' title='Boosting Performance with .NET 6 and Blazor'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrwvJ7TFRh-XmpWUTWRepIgz35u8_1K_aN0s52bKKdHhjlnEiauUe4OOv41p67beHMc90FVqIalKRhnONrX8WQth-1XRqn3Aefo5-rRyW3CCB4hbBOdoLJ3Wo3HVxMa2c0kE8gC3Idz7fpuKEWxV2mAOhTeRD2b8078driLjD7uoVE_nWT49LjEngEVuhZ/s72-w640-h426-c/internet-technology-computer-display-1089440.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-4884968886926908501</id><published>2024-10-12T23:03:00.005+05:30</published><updated>2024-10-12T23:03:50.019+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="dotnet"/><category scheme="http://www.blogger.com/atom/ns#" term="SignalR"/><title type='text'>SignalR vs WebSockets: Which One is Better for Real-Time Communication?</title><content type='html'>&lt;p&gt;Real-time communication has become a cornerstone of modern web development. Whether you&#39;re building live chat systems, real-time dashboards, or multiplayer games, you need a reliable way to maintain a two-way communication channel between clients and servers. Two popular technologies often considered for this task are &lt;strong&gt;SignalR&lt;/strong&gt; and &lt;strong&gt;WebSockets&lt;/strong&gt;. But which one is better for real-time communication? Let&#39;s dive into their differences and determine the best fit for your project.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;flex max-w-full flex-col flex-grow&quot;&gt;&lt;div class=&quot;min-h-8 text-message flex w-full flex-col items-end gap-2 whitespace-normal break-words [.text-message+&amp;amp;]:mt-5&quot; data-message-author-role=&quot;assistant&quot; data-message-id=&quot;d8a6d953-7c64-410a-8754-a5672d6016a4&quot; data-message-model-slug=&quot;gpt-4o&quot; dir=&quot;auto&quot;&gt;&lt;div class=&quot;flex w-full flex-col gap-1 empty:hidden first:pt-[3px]&quot;&gt;&lt;div class=&quot;markdown prose w-full break-words dark:prose-invert light&quot;&gt;&lt;h3&gt;What is WebSockets?&lt;/h3&gt;&lt;p&gt;WebSockets is a protocol that enables full-duplex communication between a client and a server over a single, long-lived connection. It was designed specifically to overcome the limitations of HTTP, which is request-response-based, making it unsuitable for real-time communication.&lt;/p&gt;&lt;p&gt;Once a WebSocket connection is established, both the client and server can send data to each other at any time without needing to request or wait for responses. This makes WebSockets ideal for high-frequency, real-time applications such as live data feeds, financial trading systems, and online gaming.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Key Features of WebSockets:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Bi-directional communication&lt;/strong&gt;: Both client and server can send and receive data in real-time.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Low latency&lt;/strong&gt;: Once the connection is established, communication is fast and direct.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Protocol-level solution&lt;/strong&gt;: WebSockets operates at a protocol level, making it a native option for web browsers.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;What is SignalR?&lt;/h3&gt;&lt;p&gt;SignalR is a library built on top of WebSockets, designed to simplify the implementation of real-time communication for .NET developers. It abstracts the underlying complexity of WebSockets and provides a higher-level API that can handle fallbacks (such as Long Polling and Server-Sent Events) when WebSockets is unavailable.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Key Features of SignalR:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Abstraction of multiple transport mechanisms&lt;/strong&gt;: SignalR automatically falls back to alternatives like Long Polling or Server-Sent Events if WebSockets isn&#39;t supported.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Hubs&lt;/strong&gt;: SignalR introduces the concept of hubs, which make it easy to call server-side methods from the client and vice versa.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Group communication&lt;/strong&gt;: SignalR supports broadcasting messages to specific groups, allowing for more targeted real-time messaging.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Cross-platform support&lt;/strong&gt;: SignalR can work with various clients, including JavaScript, .NET, and even &lt;strong&gt;Xamarin&lt;/strong&gt; for mobile applications.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;SignalR vs WebSockets: Which One is Better?&lt;/h3&gt;&lt;p&gt;Now that we’ve covered the basics, let’s compare &lt;strong&gt;SignalR&lt;/strong&gt; and &lt;strong&gt;WebSockets&lt;/strong&gt; across a few key dimensions:&lt;/p&gt;&lt;h4&gt;1. &lt;strong&gt;Ease of Use&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WebSockets&lt;/strong&gt;: Using WebSockets requires a deeper understanding of network programming. While the WebSocket protocol is efficient, managing connections, error handling, and fallback strategies can be complex.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SignalR&lt;/strong&gt;: SignalR simplifies the real-time communication setup. With &lt;strong&gt;built-in abstractions&lt;/strong&gt; and support for fallback options, you can focus more on application logic and less on the intricacies of network protocols.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: SignalR, for its ease of use and developer-friendly features like hubs and group messaging.&lt;/p&gt;&lt;h4&gt;2. &lt;strong&gt;Transport Mechanism&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WebSockets&lt;/strong&gt;: WebSockets operates purely at the protocol level, making it a lean and efficient solution for real-time communication. However, if WebSockets are blocked or unsupported (e.g., by corporate firewalls), you&#39;ll need to implement alternative transports manually.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SignalR&lt;/strong&gt;: SignalR can fall back to other transports like Long Polling or Server-Sent Events when WebSockets are unavailable. This makes it more robust in environments with restricted network setups.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: SignalR, for its flexibility in handling different transport mechanisms.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgufhkXAIvWtd2doA-Lxe5OWBAPXxE4FZIeWLdYvDvrpQuI5OsE97994iL3xCmHMW5hpMT3v1cp9uz48H59zrrCEmqIZPvKaNXMh6fVjjQP_wQewixOnR2vKl3nKARYalemNEpOIHPrhkzzpqDYLoOGjGSWRFa5-qOHeoVQRus2Tkc3EhpKlE85taeYUsXH/s1280/computer-monitor-coding-programming-2194062.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgufhkXAIvWtd2doA-Lxe5OWBAPXxE4FZIeWLdYvDvrpQuI5OsE97994iL3xCmHMW5hpMT3v1cp9uz48H59zrrCEmqIZPvKaNXMh6fVjjQP_wQewixOnR2vKl3nKARYalemNEpOIHPrhkzzpqDYLoOGjGSWRFa5-qOHeoVQRus2Tkc3EhpKlE85taeYUsXH/w640-h426/computer-monitor-coding-programming-2194062.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;3. &lt;strong&gt;Performance and Latency&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WebSockets&lt;/strong&gt;: With WebSockets, once the connection is established, you get minimal latency because the client and server can push updates directly to each other. It&#39;s ideal for high-frequency, low-latency applications.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SignalR&lt;/strong&gt;: SignalR adds a slight overhead because of its abstractions and fallback mechanisms. While it’s still performant, it may not achieve the ultra-low latency that pure WebSockets can provide in all scenarios.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: WebSockets, for its raw performance and low latency in optimal conditions.&lt;/p&gt;&lt;h4&gt;4. &lt;strong&gt;Scalability&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WebSockets&lt;/strong&gt;: Scaling WebSockets can be challenging because each connection consumes resources, and handling a large number of open connections can strain server resources. You often need to incorporate load balancers or use specific strategies like &lt;strong&gt;Redis&lt;/strong&gt; for scale-out.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SignalR&lt;/strong&gt;: SignalR provides built-in support for scaling out using backplanes like &lt;strong&gt;Redis&lt;/strong&gt; or &lt;strong&gt;Azure SignalR Service&lt;/strong&gt;, which simplifies scaling across multiple servers.&amp;nbsp;If you’re planning to build a real-time application that serves thousands or millions of users, SignalR’s scalability features can save a lot of headaches.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: SignalR, for its built-in scalability features.&lt;/p&gt;&lt;h4&gt;5. &lt;strong&gt;Cross-Platform Compatibility&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WebSockets&lt;/strong&gt;: WebSockets is supported in most modern browsers and server environments, but it doesn’t provide any built-in tools for cross-platform support. You would need to implement custom logic for compatibility across different platforms.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SignalR&lt;/strong&gt;: SignalR supports various clients, including &lt;strong&gt;Angular&lt;/strong&gt;, &lt;strong&gt;React&lt;/strong&gt;, &lt;strong&gt;Blazor&lt;/strong&gt;, and even &lt;strong&gt;Xamarin&lt;/strong&gt; for mobile apps. This makes it an excellent choice for building real-time applications that need to work seamlessly across different platforms and devices.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: SignalR, for its wide cross-platform compatibility.&lt;/p&gt;&lt;h4&gt;6. &lt;strong&gt;Use Cases&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WebSockets&lt;/strong&gt;: Ideal for performance-critical, real-time applications such as multiplayer games, live financial dashboards, and trading platforms.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SignalR&lt;/strong&gt;: Best for enterprise-level applications, chat apps, real-time notifications, and applications where ease of integration, scalability, and cross-platform support are more important than raw performance.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: It depends on the use case. For high-performance apps with minimal infrastructure, WebSockets is ideal. For ease of development and scaling, SignalR is a better option.&lt;/p&gt;&lt;h3&gt;Conclusion: Which One Should You Use?&lt;/h3&gt;&lt;p&gt;The answer largely depends on your needs. If you&#39;re building a performance-critical application where latency is a key factor, &lt;strong&gt;WebSockets&lt;/strong&gt; is the way to go. However, if you need a more flexible, easy-to-use, and scalable solution, &lt;strong&gt;SignalR&lt;/strong&gt; is the better choice—especially in complex applications that may involve multiple transport mechanisms and cross-platform support.&lt;/p&gt;&lt;p&gt;In short, use &lt;strong&gt;WebSockets&lt;/strong&gt; for &lt;strong&gt;high-performance&lt;/strong&gt; real-time apps with a controlled environment and &lt;strong&gt;SignalR&lt;/strong&gt; when you need flexibility, scalability, and support for fallback options.&lt;/p&gt;&lt;p&gt;If you&#39;re building with ASP.NET Core or .NET 6 and want seamless integration with frameworks like &lt;strong&gt;React&lt;/strong&gt;, &lt;strong&gt;Angular&lt;/strong&gt;, or &lt;strong&gt;Blazor&lt;/strong&gt;, SignalR can make your real-time communication setup a breeze​.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/4884968886926908501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/signalr-vs-websockets-which-one-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/4884968886926908501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/4884968886926908501'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/signalr-vs-websockets-which-one-is.html' title='SignalR vs WebSockets: Which One is Better for Real-Time Communication?'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgufhkXAIvWtd2doA-Lxe5OWBAPXxE4FZIeWLdYvDvrpQuI5OsE97994iL3xCmHMW5hpMT3v1cp9uz48H59zrrCEmqIZPvKaNXMh6fVjjQP_wQewixOnR2vKl3nKARYalemNEpOIHPrhkzzpqDYLoOGjGSWRFa5-qOHeoVQRus2Tkc3EhpKlE85taeYUsXH/s72-w640-h426-c/computer-monitor-coding-programming-2194062.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-1190746517331293327</id><published>2024-10-10T10:51:00.002+05:30</published><updated>2024-10-10T10:51:50.510+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft"/><title type='text'>How to Study for the Microsoft Certified: Data Analyst Associate Exam</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;The Microsoft Certified: Data Analyst Associate certification is an excellent choice for anyone looking to enhance their skills in data analysis, particularly with tools like Power BI. Earning this certification not only boosts your knowledge but also opens doors to career opportunities in business intelligence and data analytics.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Here’s a comprehensive guide to help you prepare, complete with a study plan, recommended resources, and exam tips. Whether you&#39;re new to data analysis or a seasoned professional, this roadmap will keep you on track.&lt;/p&gt;&lt;h3&gt;&lt;strong&gt;Introduction to the Microsoft Certified: Data Analyst Associate Exam&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;The Microsoft Certified: Data Analyst Associate exam (Exam DA-100, transitioning to PL-300) tests your ability to analyze business requirements, clean and transform data, build data models, and visualize data with Power BI. The exam focuses on how to work with Power BI to extract insights from data, making it particularly useful for professionals who regularly work with data in a business environment.&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;Skills Measured in the Exam&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;The exam covers five key areas of Power BI usage. These are the skills you’ll need to focus on:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Prepare the Data (20-25%)&lt;/strong&gt; – Understanding data sources and transforming data for use.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Model the Data (25-30%)&lt;/strong&gt; – Creating data models and optimizing performance.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Visualize the Data (20-25%)&lt;/strong&gt; – Building reports and dashboards with Power BI.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Analyze the Data (10-15%)&lt;/strong&gt; – Performing advanced analysis.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Deploy and Maintain Deliverables (10-15%)&lt;/strong&gt; – Managing workspaces, datasets, and security settings.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The percentages indicate the weight each topic has on the exam, so allocate more time to higher-weighted areas like data modeling and preparation.&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;Recommended Study Resources&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;To pass the exam, a well-rounded study approach is crucial. Here are some trusted resources that will help you prepare:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microsoft Learn&lt;/strong&gt;&lt;br /&gt;Microsoft&#39;s official learning platform offers a &lt;strong&gt;free&lt;/strong&gt; learning path for the Data Analyst Associate exam. It covers all key concepts, broken down into manageable modules, with interactive exercises and quizzes to test your knowledge.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/learn/certifications/exams/da-100&quot; rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;Microsoft Learn - DA-100 Certification Path&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Power BI Documentation&lt;/strong&gt;&lt;br /&gt;Familiarize yourself with the official Power BI documentation. This resource covers everything from setting up data sources to creating complex visualizations and reports.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/power-bi/&quot; rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;Power BI Documentation&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Practice Exams&lt;/strong&gt;&lt;br /&gt;Taking practice exams is essential for familiarizing yourself with the format and timing of the real exam. Sites like MeasureUp offer high-quality practice tests with detailed explanations for each question.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://www.measureup.com/&quot; rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;MeasureUp Practice Tests&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Power BI Community and Forums&lt;/strong&gt;&lt;br /&gt;The Power BI Community forum is a great place to ask questions, share knowledge, and learn from others who are preparing for the exam. Engaging with the community can give you a broader understanding of the tool’s real-world applications.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;Power BI Community&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Books and Video Courses&lt;/strong&gt;&lt;br /&gt;Books like &quot;Exam Ref DA-100: Analyzing Data with Microsoft Power BI&quot; provide structured study material and exam insights. Platforms like Udemy and LinkedIn Learning also offer video courses designed to help you pass the exam.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;Udemy Power BI Courses&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;4-Week Study Plan&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Here’s a 4-week study plan to guide your preparation, assuming you&#39;re studying part-time and have some familiarity with Power BI.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Week 1: Focus on Data Preparation and Modeling&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Day 1-3&lt;/strong&gt;: Learn about data sources and how to connect Power BI to various databases (SQL, Excel, etc.). Practice importing data and transforming it.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Day 4-7&lt;/strong&gt;: Deep dive into data modeling concepts, including relationships, hierarchies, and calculated columns. Set up simple data models and practice using DAX (Data Analysis Expressions).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Week 2: Build and Enhance Data Models&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Day 1-3&lt;/strong&gt;: Focus on refining data models by practicing performance optimization techniques like using variables and optimizing tables.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Day 4-7&lt;/strong&gt;: Continue with DAX functions, and learn how to create complex calculations and metrics.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Week 3: Visualizing and Analyzing Data&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Day 1-3&lt;/strong&gt;: Explore Power BI’s visualization capabilities by creating dashboards, reports, and charts. Experiment with different visual types and report features.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Day 4-7&lt;/strong&gt;: Learn to analyze data using Power BI’s built-in analytics tools. Focus on adding trend lines, using drill-downs, and forecasting.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Week 4: Review and Practice Exams&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Day 1-3&lt;/strong&gt;: Review deployment strategies, workspace management, and security features in Power BI. Focus on the &quot;Deploy and Maintain&quot; section of the exam.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Day 4-7&lt;/strong&gt;: Take full-length practice exams to simulate the real exam experience. Identify weak areas and revise them as necessary.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3H0ETUNR5rrcjaA-Kn6WDos3776FVe-tUPl-O2mInk6opnEOy6aj12CDI-N9n-q7TXzr4w2UJllMmX80eIF439hhLqyWmlmtlIl4SdOxp6HzvQ-k6m5Z2095DMPYAyFekK7FxKG7e52uSyyai7yvT1DQ_8CYyJiQh9FdXKtTttjf9rXH-XyVxzoLDVqLV/s1280/business-clean-computer-connection-389819.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3H0ETUNR5rrcjaA-Kn6WDos3776FVe-tUPl-O2mInk6opnEOy6aj12CDI-N9n-q7TXzr4w2UJllMmX80eIF439hhLqyWmlmtlIl4SdOxp6HzvQ-k6m5Z2095DMPYAyFekK7FxKG7e52uSyyai7yvT1DQ_8CYyJiQh9FdXKtTttjf9rXH-XyVxzoLDVqLV/w640-h426/business-clean-computer-connection-389819.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;Exam Preparation Tips&lt;/strong&gt;&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hands-on Practice&lt;/strong&gt;&lt;br /&gt;One of the best ways to prepare for the exam is to get as much hands-on practice as possible. Use Power BI Desktop and familiarize yourself with every aspect of the tool. Set up sample projects to apply the knowledge in real-world scenarios.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Practice Exams Wisely&lt;/strong&gt;&lt;br /&gt;Don’t just memorize practice questions—use them to understand &lt;em&gt;why&lt;/em&gt; the correct answers are right. This will deepen your understanding of key concepts and help you tackle unfamiliar questions on exam day.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Manage Your Time&lt;/strong&gt;&lt;br /&gt;The exam lasts for 180 minutes, so it’s important to practice managing your time. During practice exams, aim to finish with enough time to review your answers.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Join a Study Group&lt;/strong&gt;&lt;br /&gt;Joining a study group or engaging with the Power BI community can provide encouragement and insight. It’s also helpful to discuss challenging topics with others preparing for the same certification.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stay Calm and Confident on Exam Day&lt;/strong&gt;&lt;br /&gt;Exam nerves are common, but being well-prepared will help you remain calm. Get a good night’s rest before the exam, and take a few deep breaths before starting. Remember, you’ve got this!&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;The Microsoft Certified: Data Analyst Associate exam is a rewarding challenge that opens up a world of opportunities for data enthusiasts. By following this structured study plan, leveraging high-quality resources, and practicing diligently, you&#39;ll be well-prepared to pass the exam and elevate your career.&lt;/p&gt;&lt;p&gt;If you need personalized guidance on your journey to becoming a certified data analyst or support with data analytics projects, feel free to reach out. As a freelance programmer with experience in Power BI and data workflows, I can help you optimize your approach and succeed in the world of data analysis.&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;Good luck with your preparation!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/1190746517331293327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-study-for-microsoft-certified.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/1190746517331293327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/1190746517331293327'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-study-for-microsoft-certified.html' title='How to Study for the Microsoft Certified: Data Analyst Associate Exam'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3H0ETUNR5rrcjaA-Kn6WDos3776FVe-tUPl-O2mInk6opnEOy6aj12CDI-N9n-q7TXzr4w2UJllMmX80eIF439hhLqyWmlmtlIl4SdOxp6HzvQ-k6m5Z2095DMPYAyFekK7FxKG7e52uSyyai7yvT1DQ_8CYyJiQh9FdXKtTttjf9rXH-XyVxzoLDVqLV/s72-w640-h426-c/business-clean-computer-connection-389819.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-1761016008977203322</id><published>2024-10-09T16:33:00.002+05:30</published><updated>2024-10-09T16:33:31.312+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="learning"/><title type='text'>Best Resources for Preparing for Microsoft Certified: Azure Fundamentals</title><content type='html'>&lt;p&gt;The Microsoft Certified: Azure Fundamentals certification is a great starting point for anyone looking to validate their foundational knowledge of cloud services, specifically those provided by Microsoft Azure. Whether you’re a beginner in cloud computing or a seasoned IT professional looking to expand your skills, there are numerous resources available to help you prepare effectively. Here’s a comprehensive list of some of the best resources to get you ready for the Azure Fundamentals exam.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;1. Official Microsoft Learning Paths&lt;/h2&gt;

&lt;h3&gt;Microsoft Learn&lt;/h3&gt;

&lt;p&gt;Microsoft offers a free learning platform, &lt;strong&gt;Microsoft Learn&lt;/strong&gt;, which provides a structured path for Azure Fundamentals. The content is broken down into modules covering essential topics like cloud concepts, core Azure services, security, privacy, compliance, and Azure pricing. The interactive format includes quizzes and hands-on labs to solidify your understanding.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://learn.microsoft.com/en-us/certifications/azure-fundamentals/&quot;&gt;Microsoft Learn: Azure Fundamentals&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;2. Online Courses&lt;/h2&gt;

&lt;h3&gt;Udemy&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Udemy&lt;/strong&gt; features several high-rated courses specifically tailored for Azure Fundamentals. Look for courses that include comprehensive content, practice tests, and are frequently updated to align with the current exam objectives.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Recommended Course:&lt;/strong&gt; &quot;Microsoft Azure Fundamentals Exam AZ-900 - A Complete Study Guide.&quot;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Pluralsight&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Pluralsight&lt;/strong&gt; is another excellent resource with in-depth courses on Azure. They offer a dedicated learning path for Azure Fundamentals that includes videos, assessments, and hands-on labs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://www.pluralsight.com/paths/microsoft-azure-fundamentals&quot;&gt;Pluralsight Azure Fundamentals Learning Path&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Coursera&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Coursera&lt;/strong&gt; provides access to courses from top universities and institutions. You can find Azure-related courses that cover both the fundamentals and more advanced topics, often led by industry experts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Recommended Course:&lt;/strong&gt; &quot;Microsoft Azure Fundamentals&quot; offered by the University of Washington.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;3. Practice Tests&lt;/h2&gt;

&lt;h3&gt;Whizlabs&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Whizlabs&lt;/strong&gt; offers practice tests specifically designed for the Azure Fundamentals exam. Their tests provide detailed explanations for each answer and help you assess your readiness.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://www.whizlabs.com/azure-fundamentals/&quot;&gt;Whizlabs Azure Fundamentals Practice Tests&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;MeasureUp&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;MeasureUp&lt;/strong&gt; provides official practice tests endorsed by Microsoft. Their tests mimic the exam format and include detailed feedback, which can be beneficial for understanding your strengths and weaknesses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://www.measureup.com/Microsoft-Azure-Fundamentals-AZ-900-Practice-Test-P1512.aspx&quot;&gt;MeasureUp Azure Fundamentals Practice Test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifwEzJLbeYnFlVz-miFAGmfztaGpvDKopTCL5ZtWMqCkdhQHMGMoxA39MljZxKNHubmL3lD36MT034PqeGY6Ngrvcb5aU140bF5_M6eogVBKoeF84syy6U2VD11nVEYq3d0GssN_XVHtVKFF8AJwqtJ3LDo06aAl19YDoeX-wncC9XV18nRpBgaQfsI9iD/s2048/pexels-photo-433639.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1365&quot; data-original-width=&quot;2048&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifwEzJLbeYnFlVz-miFAGmfztaGpvDKopTCL5ZtWMqCkdhQHMGMoxA39MljZxKNHubmL3lD36MT034PqeGY6Ngrvcb5aU140bF5_M6eogVBKoeF84syy6U2VD11nVEYq3d0GssN_XVHtVKFF8AJwqtJ3LDo06aAl19YDoeX-wncC9XV18nRpBgaQfsI9iD/w640-h426/pexels-photo-433639.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2&gt;4. Books&lt;/h2&gt;

&lt;h3&gt;Exam Ref AZ-900 Microsoft Azure Fundamentals&lt;/h3&gt;

&lt;p&gt;This book, part of Microsoft’s Exam Ref series, is tailored for those preparing for the Azure Fundamentals exam. It covers key topics and concepts in a concise manner, making it an excellent supplement to online courses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Purchase Link:&lt;/strong&gt; Available on Amazon and other retailers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Azure For Architects&lt;/h3&gt;

&lt;p&gt;While slightly more advanced, this book provides insights into Azure architecture, which can help deepen your understanding of how Azure services interact. It’s a good resource to use after covering the fundamentals.&lt;/p&gt;

&lt;h2&gt;5. Community and Forums&lt;/h2&gt;

&lt;h3&gt;Microsoft Tech Community&lt;/h3&gt;

&lt;p&gt;Joining the &lt;strong&gt;Microsoft Tech Community&lt;/strong&gt; can connect you with other learners and professionals. Participating in discussions, asking questions, and sharing knowledge can provide insights and tips that enhance your study experience.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://techcommunity.microsoft.com/&quot;&gt;Microsoft Tech Community&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Reddit&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;r/AZURE&lt;/strong&gt; subreddit is another platform where you can find discussions, study tips, and resources shared by other Azure learners and professionals.&lt;/p&gt;

&lt;h2&gt;6. YouTube Channels&lt;/h2&gt;

&lt;h3&gt;Microsoft Azure YouTube Channel&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Microsoft Azure YouTube Channel&lt;/strong&gt; offers a plethora of videos, including tutorials, webinars, and live events that can help reinforce your learning.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://www.youtube.com/c/MicrosoftAzure&quot;&gt;Microsoft Azure YouTube Channel&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;FreeCodeCamp.org&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;FreeCodeCamp.org&lt;/strong&gt; frequently posts comprehensive tutorials on various Azure topics, including cloud fundamentals. Their videos are engaging and often provide real-world examples.&lt;/p&gt;

&lt;h2&gt;7. Official Documentation&lt;/h2&gt;

&lt;h3&gt;Microsoft Azure Documentation&lt;/h3&gt;

&lt;p&gt;While studying, always refer to the &lt;strong&gt;official Azure documentation&lt;/strong&gt;. It’s comprehensive and regularly updated, ensuring you have the latest information regarding Azure services.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key Link:&lt;/strong&gt; &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/&quot;&gt;Microsoft Azure Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;

&lt;p&gt;Preparing for the Microsoft Certified: Azure Fundamentals exam doesn&#39;t have to be overwhelming. With the right combination of official learning paths, online courses, practice tests, community engagement, and hands-on experience, you can build a solid foundation in Azure. Remember to stay consistent in your study efforts, take advantage of practice exams, and immerse yourself in the Azure ecosystem through hands-on labs and projects. Good luck on your journey to becoming Azure certified!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/1761016008977203322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/best-resources-for-preparing-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/1761016008977203322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/1761016008977203322'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/best-resources-for-preparing-for.html' title='Best Resources for Preparing for Microsoft Certified: Azure Fundamentals'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifwEzJLbeYnFlVz-miFAGmfztaGpvDKopTCL5ZtWMqCkdhQHMGMoxA39MljZxKNHubmL3lD36MT034PqeGY6Ngrvcb5aU140bF5_M6eogVBKoeF84syy6U2VD11nVEYq3d0GssN_XVHtVKFF8AJwqtJ3LDo06aAl19YDoeX-wncC9XV18nRpBgaQfsI9iD/s72-w640-h426-c/pexels-photo-433639.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-2067009126950633199</id><published>2024-10-09T08:32:00.003+05:30</published><updated>2024-10-09T08:32:33.679+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft"/><category scheme="http://www.blogger.com/atom/ns#" term="Power Automate"/><title type='text'>Streamline Your Day: How to Automate Workflows with Microsoft Power Automate</title><content type='html'>&lt;p&gt;In today’s fast-paced digital world, repetitive tasks can eat up valuable time and drain productivity. Whether you’re constantly sending follow-up emails, managing data entries, or switching between apps, it’s easy to get overwhelmed. What if there was a way to automate these tasks and free up time for more important things? Enter &lt;strong&gt;Microsoft Power Automate&lt;/strong&gt;—the ultimate tool for automating workflows and boosting efficiency.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;What is Microsoft Power Automate?&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Microsoft Power Automate&lt;/strong&gt; (formerly known as Microsoft Flow) is a cloud-based service that allows you to create automated workflows between different apps and services. Whether you’re working with Microsoft 365, third-party apps, or custom APIs, Power Automate connects them all seamlessly. It enables users to build both simple and complex workflows without the need for coding expertise.&lt;/p&gt;&lt;p&gt;With Power Automate, you can automate anything from &lt;strong&gt;sending reminders&lt;/strong&gt; and &lt;strong&gt;copying files&lt;/strong&gt; to &lt;strong&gt;managing approvals&lt;/strong&gt; and &lt;strong&gt;collecting data&lt;/strong&gt;—all at the click of a button.&lt;/p&gt;&lt;h3&gt;Key Benefits of Using Microsoft Power Automate&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Increased Productivity&lt;/strong&gt;:
Automating routine tasks saves time and lets you focus on more strategic work.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt;:
Power Automate ensures processes are carried out uniformly, reducing the risk of human error.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-App Integration&lt;/strong&gt;:
It supports integration with &lt;strong&gt;over 500 applications&lt;/strong&gt;, including Microsoft services (like Outlook, Excel, SharePoint, and Teams) and popular third-party apps (like Slack, Google Drive, and Trello).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customization&lt;/strong&gt;:
The platform provides a wealth of templates, but users can also create workflows from scratch, catering to specific business needs.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cloud-Based and Accessible&lt;/strong&gt;:
Since it’s cloud-based, you can access Power Automate from anywhere, whether you&#39;re working at your desk or remotely.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr /&gt;&lt;h3&gt;How to Automate Workflows with Microsoft Power Automate&lt;/h3&gt;&lt;p&gt;Ready to dive into automating your workflows? Here’s a step-by-step guide to get you started with Power Automate.&lt;/p&gt;&lt;h4&gt;Step 1: Access Microsoft Power Automate&lt;/h4&gt;&lt;p&gt;Start by visiting the &lt;a href=&quot;https://flow.microsoft.com&quot; rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;Power Automate website&lt;/a&gt; or through your Microsoft 365 subscription. If you’re using it for the first time, sign in with your Microsoft account to access the platform.&lt;/p&gt;&lt;h4&gt;Step 2: Explore Pre-Built Templates&lt;/h4&gt;&lt;p&gt;If you&#39;re new to automation, Power Automate offers hundreds of &lt;strong&gt;pre-built templates&lt;/strong&gt; designed for common workflows. Browse through the templates to find one that fits your need, whether it&#39;s automating email alerts, integrating Microsoft Teams with SharePoint, or posting notifications in Slack.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Example: Automate sending a &lt;strong&gt;daily report&lt;/strong&gt; email from a SharePoint list using Outlook.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAClNS5zlF5dYcz5yLqr6T8EDoqgA7qp4HpQxYyG-BDVRmbe-bkaYmvV5IeaqVgTNRvFk1QlRgQIuKikQQm84Lc6jGhZHIXW9R86U7W9_u2fsUYVSJHGNDRzhZpbkMsYQxkdK4t7-Dt0HDK0idRZVRRvFtwQpWrxJ_x0LAouWP33kHbrVQuIXfYu47-fyq/s1280/photo-of-laptop-near-camera-1029139.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;960&quot; data-original-width=&quot;1280&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAClNS5zlF5dYcz5yLqr6T8EDoqgA7qp4HpQxYyG-BDVRmbe-bkaYmvV5IeaqVgTNRvFk1QlRgQIuKikQQm84Lc6jGhZHIXW9R86U7W9_u2fsUYVSJHGNDRzhZpbkMsYQxkdK4t7-Dt0HDK0idRZVRRvFtwQpWrxJ_x0LAouWP33kHbrVQuIXfYu47-fyq/w640-h480/photo-of-laptop-near-camera-1029139.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4&gt;Step 3: Create a Workflow from Scratch&lt;/h4&gt;&lt;p&gt;To create a custom workflow, click on &lt;strong&gt;Create&lt;/strong&gt; in the Power Automate dashboard and choose the type of flow that best suits your task.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Automated Flow&lt;/strong&gt;: Triggered by an event, such as receiving an email or a new item being added to SharePoint.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Instant Flow&lt;/strong&gt;: Manually triggered by a user action (e.g., a button press).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Scheduled Flow&lt;/strong&gt;: Runs at scheduled intervals.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Business Process Flow&lt;/strong&gt;: Guides users through specific business processes.&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;Step 4: Choose a Trigger&lt;/h4&gt;&lt;p&gt;Every workflow in Power Automate starts with a trigger—an event that initiates the automation. For example:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;When a new email arrives in Outlook&lt;/strong&gt;, move attachments to OneDrive.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;When a new tweet mentions your brand&lt;/strong&gt;, log it in an Excel sheet.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;After selecting your trigger, connect the relevant service by logging into your account.&lt;/p&gt;&lt;h4&gt;Step 5: Add Actions&lt;/h4&gt;&lt;p&gt;Once the trigger is set, add &lt;strong&gt;actions&lt;/strong&gt;—the tasks you want to automate. Power Automate allows you to chain multiple actions together. For instance:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;When a form response is submitted, send a notification to Microsoft Teams and create a task in Planner.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can configure each action with conditions, filters, and variables to suit your exact workflow needs.&lt;/p&gt;&lt;h4&gt;Step 6: Test and Activate Your Flow&lt;/h4&gt;&lt;p&gt;After building your workflow, it’s time to test it. Run a few test cases to ensure that your flow works as expected. Power Automate provides a visual log of the process, allowing you to see the status of each step and troubleshoot if necessary.&lt;/p&gt;&lt;p&gt;Once satisfied, &lt;strong&gt;activate&lt;/strong&gt; the flow, and watch your tasks get automated!&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;Popular Use Cases for Power Automate&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automating Email Responses&lt;/strong&gt;:
Tired of sending the same email multiple times? Use Power Automate to send &lt;strong&gt;automatic replies&lt;/strong&gt; or forward important emails to the right person.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Social Media Management&lt;/strong&gt;:
You can automate the collection of mentions or hashtags related to your brand and log them in an Excel spreadsheet for easy tracking.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Approvals&lt;/strong&gt;:
Streamline your approval process by sending automatic notifications when a document needs approval, and then notifying relevant stakeholders once it&#39;s approved.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Synchronization&lt;/strong&gt;:
Power Automate helps keep all your data consistent across platforms. For example, you can automatically copy new contacts from Outlook to a Google Sheet or Salesforce.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Notifications and Alerts&lt;/strong&gt;:
Automatically get notified when specific conditions are met, like when a large file is uploaded to SharePoint or when an important client email arrives.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr /&gt;&lt;h3&gt;Power Automate Tips for Maximizing Workflow Efficiency&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Start with Templates&lt;/strong&gt;: Templates can help you understand how Power Automate works. Modify them to suit your specific needs.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Leverage Conditional Logic&lt;/strong&gt;: Set conditions to trigger different actions based on certain criteria. This adds flexibility to your automation.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Integrate Multiple Apps&lt;/strong&gt;: Don’t limit yourself to just one app. Connect various tools you use daily, like Dropbox, Microsoft Teams, Excel, and Slack.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Monitor Performance&lt;/strong&gt;: Check the flow history in Power Automate to ensure everything is running smoothly and to identify any potential issues.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Use Approval Flows&lt;/strong&gt;: When dealing with processes that require multiple levels of approval, set up approval workflows to ensure a smooth review process.&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;p&gt;Microsoft Power Automate is a game-changer for anyone looking to streamline their day-to-day tasks. With its easy-to-use interface and wide range of integrations, you can build simple or complex workflows without needing to write a single line of code. Whether you&#39;re automating mundane tasks like data entry or enhancing complex business processes, Power Automate helps you work smarter, not harder.&lt;/p&gt;&lt;p&gt;So, what are you waiting for? Start automating today and reclaim your time!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/2067009126950633199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/streamline-your-day-how-to-automate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/2067009126950633199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/2067009126950633199'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/streamline-your-day-how-to-automate.html' title='Streamline Your Day: How to Automate Workflows with Microsoft Power Automate'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAClNS5zlF5dYcz5yLqr6T8EDoqgA7qp4HpQxYyG-BDVRmbe-bkaYmvV5IeaqVgTNRvFk1QlRgQIuKikQQm84Lc6jGhZHIXW9R86U7W9_u2fsUYVSJHGNDRzhZpbkMsYQxkdK4t7-Dt0HDK0idRZVRRvFtwQpWrxJ_x0LAouWP33kHbrVQuIXfYu47-fyq/s72-w640-h480-c/photo-of-laptop-near-camera-1029139.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-3902440333759021025</id><published>2024-10-08T10:35:00.003+05:30</published><updated>2024-10-08T10:35:37.618+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows 11"/><title type='text'>How to Customize the Windows 11 Taskbar for Improved Productivity</title><content type='html'>&lt;p&gt;The Windows 11 taskbar is a powerful tool that can significantly enhance your productivity when properly customized. With its new design and features, it offers various options to tailor your workspace to your needs. Here’s a guide on how to customize the Windows 11 taskbar for improved efficiency and a personalized experience.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;1. &lt;strong&gt;Pin Your Most Used Apps&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Pinning your frequently used applications to the taskbar allows for quick access, saving you time and effort.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Pin Apps:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Right-click on any app in the Start menu or on the desktop.&lt;/li&gt;&lt;li&gt;Select &lt;strong&gt;Pin to taskbar&lt;/strong&gt; from the context menu.&lt;/li&gt;&lt;li&gt;To rearrange pinned apps, click and drag them to your desired position on the taskbar.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;2. &lt;strong&gt;Customize the Taskbar Alignment&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Windows 11 introduced a centered taskbar, which can be shifted to the left for a more traditional look. Depending on your preference, adjusting the alignment can enhance usability.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Change Taskbar Alignment:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Right-click on the taskbar and select &lt;strong&gt;Taskbar settings&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Scroll down to the &lt;strong&gt;Taskbar behaviors&lt;/strong&gt; section.&lt;/li&gt;&lt;li&gt;Find the &lt;strong&gt;Taskbar alignment&lt;/strong&gt; option and select &lt;strong&gt;Left&lt;/strong&gt; or &lt;strong&gt;Center&lt;/strong&gt; from the dropdown menu.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;3. &lt;strong&gt;Utilize Taskbar Widgets&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Windows 11 includes a Widgets feature that provides quick access to news, weather, calendar events, and more. Customizing these widgets can help keep you informed without interrupting your workflow.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Add Widgets:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Click on the &lt;strong&gt;Widgets&lt;/strong&gt; icon on the taskbar (a square with various icons).&lt;/li&gt;&lt;li&gt;Explore the available widgets and select the ones you want to add.&lt;/li&gt;&lt;li&gt;You can also customize the content of each widget to show information relevant to you.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;4. &lt;strong&gt;Hide Unnecessary Icons&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;A cluttered taskbar can be distracting. Windows 11 allows you to hide icons for apps you rarely use, keeping your workspace organized.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Hide Taskbar Icons:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Right-click on the taskbar and select &lt;strong&gt;Taskbar settings&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Under &lt;strong&gt;Taskbar corner overflow&lt;/strong&gt;, choose which icons you want to show or hide by toggling the switches.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1IFRzZt8C0tn8iZQe5cMEZa7yAm0VGk9eDJjYGLiP5QsMArlCGvYZNpxoqsz3-4x2rCLXM3eFbXAravS5-PZ-XMUlkYNVhHSqdg4peivB_Pq5bHBK8wakHlz3KRnsEvpA0ITmDMkQ6gBabikKkl7Kiz_ctBPzcNeafCz_o7dR7fLqT-ZZQyIflaJ_KuHH/s1920/Dentech-Image-1920x1024.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1024&quot; data-original-width=&quot;1920&quot; height=&quot;342&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1IFRzZt8C0tn8iZQe5cMEZa7yAm0VGk9eDJjYGLiP5QsMArlCGvYZNpxoqsz3-4x2rCLXM3eFbXAravS5-PZ-XMUlkYNVhHSqdg4peivB_Pq5bHBK8wakHlz3KRnsEvpA0ITmDMkQ6gBabikKkl7Kiz_ctBPzcNeafCz_o7dR7fLqT-ZZQyIflaJ_KuHH/w640-h342/Dentech-Image-1920x1024.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;5. &lt;strong&gt;Enable Taskbar Toolbars&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;If you use specific folders or tools frequently, enabling taskbar toolbars can enhance your workflow. This feature allows you to add toolbars for quick access to files or shortcuts.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Enable Toolbars:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Right-click on the taskbar and hover over &lt;strong&gt;Toolbars&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Select &lt;strong&gt;New toolbar…&lt;/strong&gt; to create a new one and choose a folder to display.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;6. &lt;strong&gt;Use Virtual Desktops for Better Organization&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Windows 11 supports virtual desktops, allowing you to create separate workspaces for different tasks. You can customize the taskbar for each virtual desktop to keep your workflow organized.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Set Up Virtual Desktops:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Click the &lt;strong&gt;Task View&lt;/strong&gt; button (two overlapping squares) on the taskbar.&lt;/li&gt;&lt;li&gt;Click &lt;strong&gt;New desktop&lt;/strong&gt; to create a new virtual desktop.&lt;/li&gt;&lt;li&gt;You can customize the taskbar for each desktop by pinning different apps to each one.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;7. &lt;strong&gt;Customize Taskbar Colors&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Changing the taskbar color can improve your overall user experience. A personalized color scheme can make your workspace more visually appealing and less monotonous.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Change Taskbar Color:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Go to &lt;strong&gt;Settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;Personalization&lt;/strong&gt; &amp;gt; &lt;strong&gt;Colors&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Scroll down to &lt;strong&gt;Choose your color&lt;/strong&gt; and select a color mode (Light, Dark, or Custom).&lt;/li&gt;&lt;li&gt;Adjust the accent color to your liking, which will affect the taskbar and other UI elements.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;8. &lt;strong&gt;Access Quick Settings Easily&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;The Quick Settings menu allows you to adjust settings like Wi-Fi, Bluetooth, and volume without navigating through multiple menus. Customizing this area can save time when making adjustments.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Customize Quick Settings:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Click on the &lt;strong&gt;Network, Volume, or Battery&lt;/strong&gt; icon in the taskbar.&lt;/li&gt;&lt;li&gt;In the Quick Settings menu, click on the pencil icon to edit and add shortcuts for features you use most.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;9. &lt;strong&gt;Keyboard Shortcuts for Taskbar Management&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Familiarizing yourself with keyboard shortcuts can enhance your productivity while using the taskbar.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Useful Shortcuts:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Win + T&lt;/strong&gt;: Focus on the taskbar, allowing you to navigate pinned apps using the arrow keys.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Win + [Number]&lt;/strong&gt;: Open the app pinned to the taskbar in that position (e.g., Win + 1 for the first app).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Alt + F4&lt;/strong&gt;: Close the active window, which is useful for quickly clearing distractions.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;10. &lt;strong&gt;Explore Taskbar Settings for More Options&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Windows 11 offers various settings to further customize your taskbar experience.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to Access Taskbar Settings:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Right-click on the taskbar and select &lt;strong&gt;Taskbar settings&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Explore options like &lt;strong&gt;Taskbar behaviors&lt;/strong&gt;, &lt;strong&gt;Taskbar corner overflow&lt;/strong&gt;, and &lt;strong&gt;System tray icons&lt;/strong&gt; to find additional settings that suit your needs.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;p&gt;Customizing the Windows 11 taskbar can significantly improve your productivity by tailoring your workspace to your preferences and workflows. By following these steps, you can create a more efficient and enjoyable computing experience. Whether it&#39;s pinning your most-used apps, utilizing widgets, or adjusting the taskbar alignment, each change can make a noticeable difference in how you interact with your computer. Take the time to explore these options and discover how a personalized taskbar can enhance your daily tasks.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&quot;Windows 11&quot; by &lt;a href=&quot;https://unltdbusiness.com/microsoft-upgrade-to-11/&quot;&gt;unltdbusiness.com&lt;/a&gt;, licensed under &lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Creative Commons BY-SA 4.0&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/3902440333759021025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-customize-windows-11-taskbar-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3902440333759021025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3902440333759021025'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-customize-windows-11-taskbar-for.html' title='How to Customize the Windows 11 Taskbar for Improved Productivity'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1IFRzZt8C0tn8iZQe5cMEZa7yAm0VGk9eDJjYGLiP5QsMArlCGvYZNpxoqsz3-4x2rCLXM3eFbXAravS5-PZ-XMUlkYNVhHSqdg4peivB_Pq5bHBK8wakHlz3KRnsEvpA0ITmDMkQ6gBabikKkl7Kiz_ctBPzcNeafCz_o7dR7fLqT-ZZQyIflaJ_KuHH/s72-w640-h342-c/Dentech-Image-1920x1024.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-8265110850201217485</id><published>2024-10-07T08:40:00.004+05:30</published><updated>2024-10-07T08:40:42.633+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="One Note"/><category scheme="http://www.blogger.com/atom/ns#" term="Project Management"/><title type='text'>Best Practices for Using Microsoft OneNote for Project Management</title><content type='html'>&lt;p&gt;Microsoft OneNote is often thought of as a note-taking app, but with the right approach, it can be a powerful tool for managing projects. It combines flexibility, structure, and integration with other Microsoft Office tools, making it a versatile platform for organizing tasks, documents, and ideas.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;In this article, we will explore how to effectively use OneNote for project management, outlining best practices for setting up notebooks, tracking tasks, managing teams, and ensuring successful project outcomes.&lt;/p&gt;&lt;h3&gt;&lt;strong&gt;Why Use OneNote for Project Management?&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;While there are dedicated project management tools like Trello, Asana, or Microsoft Project, OneNote has several advantages, particularly for smaller teams or individuals looking for simplicity:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Flexibility:&lt;/strong&gt; OneNote is a freeform tool that allows users to organize their information however they see fit, without rigid structures.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Integration with Microsoft 365:&lt;/strong&gt; OneNote seamlessly integrates with Microsoft Outlook, Word, Excel, and Teams, allowing easy synchronization of tasks, emails, and schedules.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Collaboration:&lt;/strong&gt; With OneNote’s cloud-based features, multiple people can collaborate on a notebook simultaneously, making it easy for teams to work together on shared projects.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Ease of Use:&lt;/strong&gt; OneNote’s intuitive design allows users to easily create, move, and organize content, without the steep learning curve of more complex tools.&lt;/li&gt;&lt;/ol&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;1. Structuring Your OneNote Notebook&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;To effectively manage a project in OneNote, the first step is to establish a logical structure. OneNote notebooks can be divided into sections, and sections can contain multiple pages. Here’s a suggested structure for project management:&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Notebooks&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;Each project should have its own notebook. This keeps your work organized and makes it easier to focus on specific tasks and milestones. For example, if you are managing multiple projects at the same time, separate notebooks allow for quick access and separation of tasks.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Sections&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;Within each notebook, use sections to break down the project into logical categories. Common sections for a project might include:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Project Overview:&lt;/strong&gt; For project goals, scope, and timelines.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Meeting Notes:&lt;/strong&gt; For capturing meeting agendas, minutes, and follow-ups.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Task Management:&lt;/strong&gt; For listing and tracking tasks and action items.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Documents and Resources:&lt;/strong&gt; A place to store any key documents or links relevant to the project.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Client/Stakeholder Information:&lt;/strong&gt; Keep track of key contacts, communications, and updates.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Budget and Expenses:&lt;/strong&gt; To track the financial aspects of the project.&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;&lt;strong&gt;Pages&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;Pages within sections can be further broken down into specific details or tasks. For example, in the &lt;strong&gt;Task Management&lt;/strong&gt; section, each page could represent a different team member or milestone. Under &lt;strong&gt;Meeting Notes&lt;/strong&gt;, each page could represent a different meeting.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt;&lt;br /&gt;OneNote supports subpages, which can be used to further organize information within a page. For example, under a &lt;strong&gt;Project Overview&lt;/strong&gt; page, you could create subpages for timelines, objectives, and deliverables.&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;2. Use Tags for Task Management&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Tags are one of OneNote’s most powerful features for project management. They help you label and categorize different types of information quickly. Here’s how you can use tags effectively:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;To-Do Tags:&lt;/strong&gt; Use the built-in checkbox feature to create task lists. This helps track action items and ensures nothing gets missed. When a task is completed, you can simply check it off.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Priority Tags:&lt;/strong&gt; OneNote allows you to tag items with priority labels like &quot;Important&quot; or &quot;Critical.&quot; This is helpful for identifying tasks that need immediate attention.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Meeting Tags:&lt;/strong&gt; Use the &quot;Meeting&quot; tag to highlight important notes from project meetings, making it easier to follow up on decisions or action points later.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Custom Tags:&lt;/strong&gt; You can create custom tags for specific project needs, such as &quot;Deadline,&quot; &quot;Pending Approval,&quot; or &quot;Follow Up.&quot;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt;&lt;br /&gt;Use OneNote’s &lt;strong&gt;Find Tags&lt;/strong&gt; feature (in the Home tab) to see all tagged items across your notebook in one place. This is an excellent way to review outstanding tasks, important notes, and critical action items.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTyOw9BDDydXlHllt7WJw8PuPGKQkEW0wTC9pdryfX6tr3UFbvqtHu_e_FdLXE7vQp1cZC52L3kO5DCiJO5ySpdwNss43BB5FDKbmOpQoTIBYvN_ciuMfFesHacW6lVboSJZqekrzTllfIonZR17266CpJQbxUxyfiLwVqTgKTfgXCZCVgEZiIbRCbH54a/s1280/business-clean-computer-connection-389819.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTyOw9BDDydXlHllt7WJw8PuPGKQkEW0wTC9pdryfX6tr3UFbvqtHu_e_FdLXE7vQp1cZC52L3kO5DCiJO5ySpdwNss43BB5FDKbmOpQoTIBYvN_ciuMfFesHacW6lVboSJZqekrzTllfIonZR17266CpJQbxUxyfiLwVqTgKTfgXCZCVgEZiIbRCbH54a/w640-h426/business-clean-computer-connection-389819.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;3. Integration with Outlook and Teams&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;One of OneNote’s most valuable features for project management is its ability to integrate with other Microsoft 365 tools. These integrations can save time, reduce duplication, and keep all project information in one place.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Outlook Integration&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Convert Notes to Tasks:&lt;/strong&gt; You can easily create Outlook tasks from OneNote. Highlight an action item, right-click, and select &quot;Outlook Tasks.&quot; This will sync the task with your Outlook calendar and to-do list.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Send Meeting Notes to OneNote:&lt;/strong&gt; After a meeting in Outlook, you can directly send the agenda and meeting notes to OneNote for storage and follow-up.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Email to OneNote:&lt;/strong&gt; If you receive an important email that needs to be stored or tracked as part of a project, you can send it to OneNote via Outlook using the &quot;Send to OneNote&quot; button.&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;&lt;strong&gt;Microsoft Teams Integration&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;For teams using Microsoft Teams, OneNote can be integrated directly into a team channel:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Shared Notebooks:&lt;/strong&gt; Create a shared OneNote notebook in a Teams channel, so all team members can contribute to project planning, track tasks, and store meeting notes.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Collaboration:&lt;/strong&gt; Team members can work on the same OneNote notebook simultaneously, allowing for real-time collaboration on meeting notes, tasks, and brainstorming.&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;4. Track Project Progress with Checklists and Timelines&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;While OneNote doesn’t have built-in Gantt charts or project timelines like more advanced project management tools, you can still effectively track progress using custom checklists, timelines, and tables.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Create Project Checklists:&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;Use OneNote’s checklist feature to break down the project into specific tasks or milestones. You can create checklists for each phase of the project (e.g., design, development, testing) and assign deadlines.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Visual Timelines:&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;To track a project timeline, you can manually create a table or use OneNote’s drawing tools to sketch out a basic timeline. Assign dates and deadlines to each phase, and use tags to highlight important deliverables.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Progress Monitoring:&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;Set up pages dedicated to tracking progress, where you can update the status of each task, record blockers, and celebrate milestones. For example:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;On Track:&lt;/strong&gt; Tasks progressing according to schedule.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;At Risk:&lt;/strong&gt; Tasks behind schedule or in danger of missing deadlines.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Completed:&lt;/strong&gt; A log of finished tasks to help you monitor overall project completion.&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;5. Collaborate and Share with Your Team&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;OneNote is a collaborative platform that allows teams to work together efficiently. For effective collaboration:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Share Notebooks:&lt;/strong&gt; OneNote allows you to share entire notebooks or specific sections with others. If you’re working on a project with multiple stakeholders, everyone can access the same information, reducing the need for long email chains or status updates.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Real-Time Collaboration:&lt;/strong&gt; Team members can edit the same notebook simultaneously, and changes will appear in real-time. This is useful during meetings when multiple people may want to add notes, tasks, or ideas.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Permission Settings:&lt;/strong&gt; Set permissions based on roles. For example, some users can have &quot;view only&quot; access, while others can be allowed to edit and contribute.&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;6. Use Templates for Consistency&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Consistency is important when managing projects across different teams or clients. OneNote allows you to create custom templates, which can be a big time-saver.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;How to Use Templates:&lt;/strong&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;Create a standard &lt;strong&gt;Meeting Agenda&lt;/strong&gt; template, with sections for attendees, agenda items, discussion points, and follow-up tasks.&lt;/li&gt;&lt;li&gt;Develop a &lt;strong&gt;Project Kickoff&lt;/strong&gt; template, with predefined sections for project objectives, stakeholders, timeline, and resources.&lt;/li&gt;&lt;li&gt;Save a &lt;strong&gt;Task Tracker&lt;/strong&gt; template that includes a table or checklist layout for tracking deadlines, progress, and assignments.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can easily reuse these templates for every new project, ensuring consistency and professionalism.&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;7. Capture Ideas and Brainstorm with Freedom&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Unlike rigid project management tools, OneNote allows for freeform note-taking and brainstorming. You can use it to capture ideas, sketches, or random thoughts, and then organize them later. This is especially useful in the early phases of a project, where brainstorming and creative input are crucial.&lt;/p&gt;&lt;h4&gt;&lt;strong&gt;Mind Maps and Visual Thinking:&lt;/strong&gt;&lt;/h4&gt;&lt;p&gt;OneNote’s drawing tools enable you to create quick mind maps or flowcharts, which are helpful for visualizing complex ideas, processes, or project structures. You can draw directly on the page or insert shapes to organize thoughts in a non-linear way.&lt;/p&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;8. Keep Everything in One Place with Linked Content&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;OneNote makes it easy to store and link relevant content so that everything related to a project is in one place:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Link to Files and Documents:&lt;/strong&gt; You can link to important project files (Excel sheets, PDFs, etc.) directly in your notebook, or even insert entire documents so they’re accessible from within OneNote.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Add Hyperlinks:&lt;/strong&gt; If your project involves online resources, research, or external documents, you can easily link to these pages, keeping all key resources connected to your notes.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Insert Screenshots:&lt;/strong&gt; You can capture and insert screenshots directly into your notebook, which is especially useful for project planning, design reviews, or documenting technical specifications.&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;h3&gt;&lt;strong&gt;9. Stay Organized with Search and Tags&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;As your project notebook grows, it can become difficult to find specific notes or tasks. OneNote’s &lt;strong&gt;search functionality&lt;/strong&gt; is extremely powerful:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Search across notebooks:&lt;/strong&gt; You can search across all your notebooks or limit the search to a specific section or page.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Tag search:&lt;/strong&gt; Use the &quot;Find Tags&quot; feature to locate any tagged content, helping you quickly find to-do items, important notes, or action items.&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Microsoft OneNote is an incredibly versatile tool that, when used effectively, can serve as a robust project management system. Its flexibility, integration with Microsoft 365, and collaboration features make it ideal for small-to-medium projects or individuals looking to manage their workload without the complexity of more advanced project management software.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;By establishing a clear structure, utilizing tags, integrating with other tools like Outlook, and embracing OneNote’s collaborative features, you can ensure that your projects stay organized, on track, and completed on time.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/8265110850201217485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/best-practices-for-using-microsoft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/8265110850201217485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/8265110850201217485'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/best-practices-for-using-microsoft.html' title='Best Practices for Using Microsoft OneNote for Project Management'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTyOw9BDDydXlHllt7WJw8PuPGKQkEW0wTC9pdryfX6tr3UFbvqtHu_e_FdLXE7vQp1cZC52L3kO5DCiJO5ySpdwNss43BB5FDKbmOpQoTIBYvN_ciuMfFesHacW6lVboSJZqekrzTllfIonZR17266CpJQbxUxyfiLwVqTgKTfgXCZCVgEZiIbRCbH54a/s72-w640-h426-c/business-clean-computer-connection-389819.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-757107039702406524</id><published>2024-10-06T10:13:00.005+05:30</published><updated>2024-10-06T10:13:58.541+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Teams"/><title type='text'>How to Integrate Microsoft Teams with SharePoint for Document Management</title><content type='html'>&lt;p&gt;In today’s collaborative work environment, organizations need seamless solutions to manage documents efficiently. Integrating &lt;strong&gt;Microsoft Teams&lt;/strong&gt; with &lt;strong&gt;SharePoint&lt;/strong&gt; provides a powerful combination that simplifies document management by offering a centralized location to store, share, and collaborate on files while using the communication capabilities of Teams.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;In this article, we&#39;ll guide you through the process of integrating Microsoft Teams with SharePoint for effective document management, ensuring that your team can work together smoothly while maintaining organization and control over files.&lt;/p&gt;&lt;h3&gt;Why Integrate Microsoft Teams with SharePoint?&lt;/h3&gt;&lt;p&gt;Before diving into the steps, it’s important to understand the benefits of this integration:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Centralized document storage&lt;/strong&gt;: SharePoint acts as the backend file storage for Microsoft Teams, providing a single source of truth for all documents.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Collaborative file editing&lt;/strong&gt;: Multiple team members can work on documents simultaneously, making real-time updates.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Easy access control&lt;/strong&gt;: Permissions and sharing settings can be managed through SharePoint’s robust access control features.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Version history&lt;/strong&gt;: SharePoint maintains a version history of all documents, allowing you to track changes and restore previous versions.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Streamlined communication and file management&lt;/strong&gt;: Teams provides a communication platform, and SharePoint handles the document management, making collaboration smoother.&lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;Step-by-Step Guide to Integrate Microsoft Teams with SharePoint&lt;/h3&gt;&lt;h4&gt;Step 1: Create a Microsoft Teams Channel&lt;/h4&gt;&lt;p&gt;When you create a new team in Microsoft Teams, a &lt;strong&gt;SharePoint site&lt;/strong&gt; is automatically created for that team. Each team also has &lt;strong&gt;channels&lt;/strong&gt;, and each channel has its own dedicated document folder in the connected SharePoint site.&lt;/p&gt;&lt;p&gt;To create a new team and channel:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Open Microsoft Teams and go to &lt;strong&gt;Teams&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Click &lt;strong&gt;Join or create a team&lt;/strong&gt; at the bottom.&lt;/li&gt;&lt;li&gt;Choose &lt;strong&gt;Create team&lt;/strong&gt; and give your team a name and description.&lt;/li&gt;&lt;li&gt;Once the team is created, add channels for specific departments or projects by clicking on the three dots (…) next to the team name and selecting &lt;strong&gt;Add channel&lt;/strong&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Each channel will automatically have its own folder in the SharePoint document library.&lt;/p&gt;&lt;h4&gt;Step 2: Access SharePoint from Microsoft Teams&lt;/h4&gt;&lt;p&gt;You can access the SharePoint site that is linked to your team directly from within Microsoft Teams. Here’s how:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;In Microsoft Teams, navigate to the &lt;strong&gt;Files&lt;/strong&gt; tab at the top of any channel.&lt;/li&gt;&lt;li&gt;Click on &lt;strong&gt;Open in SharePoint&lt;/strong&gt;. This will take you to the SharePoint document library that is associated with the current team and channel.&lt;/li&gt;&lt;li&gt;In the SharePoint document library, you’ll see folders corresponding to each channel of your team. These folders contain the files that are shared within the channel.&lt;/li&gt;&lt;/ol&gt;&lt;h4&gt;Step 3: Upload and Manage Documents in SharePoint&lt;/h4&gt;&lt;p&gt;To manage your documents effectively, you can use SharePoint&#39;s rich set of document management features, such as version control, metadata tagging, and access permissions.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Uploading Documents&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You can upload documents directly in Teams under the &lt;strong&gt;Files&lt;/strong&gt; tab or in SharePoint itself. Any document uploaded in Teams will automatically be synced to the SharePoint site for that team.&lt;/li&gt;&lt;li&gt;Drag-and-drop files into the &lt;strong&gt;Files&lt;/strong&gt; tab of a channel, or use the &lt;strong&gt;Upload&lt;/strong&gt; button to browse your computer.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Organizing Files&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Within SharePoint, you can create additional folders and subfolders to organize your documents by project, team, or other categories.&lt;/li&gt;&lt;li&gt;You can also set up metadata for documents, such as tags or custom properties, to help classify and retrieve files easily.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Version Control&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;SharePoint automatically tracks versions of documents. To view or restore a previous version of a document, right-click on the file in SharePoint, select &lt;strong&gt;Version history&lt;/strong&gt;, and view or restore older versions.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sharing Files&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You can share files stored in SharePoint with other team members or external users. Simply right-click the file in SharePoint or Teams, click &lt;strong&gt;Share&lt;/strong&gt;, and configure the sharing permissions.&lt;/li&gt;&lt;li&gt;You can also set expiration dates and access restrictions for shared files, ensuring enhanced security.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h4&gt;Step 4: Collaborate on Documents&lt;/h4&gt;&lt;p&gt;Collaboration is at the core of the Teams and SharePoint integration. Here’s how you can collaborate efficiently:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Simultaneous Editing&lt;/strong&gt;: When a file is uploaded in a Teams channel, members can edit it simultaneously. Whether it’s a Word document, Excel sheet, or PowerPoint presentation, multiple people can make changes in real-time.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Co-Authoring&lt;/strong&gt;: SharePoint’s document library allows for co-authoring on documents. You can see who else is editing the file, what changes are being made, and collaborate without waiting for others to finish their work.&lt;/li&gt;&lt;/ol&gt;&lt;h4&gt;Step 5: Manage Access and Permissions&lt;/h4&gt;&lt;p&gt;SharePoint provides robust permission management tools. You can control who has access to what documents at both the channel and folder level.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adjust Permissions&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Navigate to your SharePoint document library.&lt;/li&gt;&lt;li&gt;Click on the &lt;strong&gt;Settings&lt;/strong&gt; icon and select &lt;strong&gt;Site permissions&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;You can modify permissions for the entire SharePoint site, individual folders, or specific files. Grant or restrict access to team members, clients, or external collaborators by adjusting these settings.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Private Channels&lt;/strong&gt;:&lt;/p&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;If you want to create a more private space, you can create a &lt;strong&gt;Private Channel&lt;/strong&gt; in Teams. Documents shared in private channels are stored in a separate document library with more restricted access.&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip87b8a6V9xSqWZeMpS32cI7v5bM9VIfD4jLwJZ-26gl9uRCl2YmVZv-_7cxydM_0lTM7Pu6xWAeTtJQwJS_DHD6vnATIhUjftrttSi8rc5i8BzznxoiWTVBpnqSqxJZtmoEwOJllxACY-XJKF1QPupB6R09umowZIWEd_DTFm-M66xFt0-wE_7guKIzl9/s6192/TeamDevices.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;3131&quot; data-original-width=&quot;6192&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip87b8a6V9xSqWZeMpS32cI7v5bM9VIfD4jLwJZ-26gl9uRCl2YmVZv-_7cxydM_0lTM7Pu6xWAeTtJQwJS_DHD6vnATIhUjftrttSi8rc5i8BzznxoiWTVBpnqSqxJZtmoEwOJllxACY-XJKF1QPupB6R09umowZIWEd_DTFm-M66xFt0-wE_7guKIzl9/w640-h324/TeamDevices.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4&gt;Step 6: Leverage SharePoint Features Inside Microsoft Teams&lt;/h4&gt;&lt;p&gt;To further enhance your document management process, you can integrate SharePoint apps and features directly into Teams:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add a SharePoint Document Library as a Tab&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;In any Teams channel, click the &lt;strong&gt;+&lt;/strong&gt; icon to add a new tab.&lt;/li&gt;&lt;li&gt;Select &lt;strong&gt;Document Library&lt;/strong&gt; from the options, then link it to a specific SharePoint document library.&lt;/li&gt;&lt;li&gt;This allows you to access a full document library directly from Teams without needing to leave the platform.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automate Document Workflows&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Use SharePoint’s built-in workflow automation tools (such as &lt;strong&gt;Power Automate&lt;/strong&gt;) to set up document approval processes or other repetitive tasks. You can automate workflows such as document approvals, review cycles, or notifications.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;Best Practices for Document Management with Teams and SharePoint&lt;/h3&gt;&lt;p&gt;To maximize your productivity, consider the following best practices:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Keep file structures simple&lt;/strong&gt;: Organize files logically but avoid creating overly complex folder hierarchies.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Leverage metadata&lt;/strong&gt;: Use metadata to categorize documents instead of relying solely on folders. Metadata makes searching for and filtering documents easier.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Regularly review permissions&lt;/strong&gt;: Ensure that access permissions are regularly updated, especially for sensitive documents, and revoke access to users who no longer need it.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Use versioning to track changes&lt;/strong&gt;: Rely on version history to monitor document edits, which helps prevent data loss or confusion when multiple team members collaborate.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Integrating Microsoft Teams with SharePoint for document management offers a robust solution for collaborating and managing files in one place. By leveraging Teams&#39; communication capabilities and SharePoint’s advanced document management features, your organization can streamline workflows, improve collaboration, and maintain better control over documents.&lt;/p&gt;&lt;p&gt;The seamless integration allows for real-time editing, centralized storage, version control, and powerful access management—all while staying within the familiar Microsoft ecosystem.&lt;/p&gt;&lt;li style=&quot;text-align: left;&quot;&gt;&quot;TeamDevices.png&quot; by &lt;a href=&quot;https://www.technetics.com.au/it-communication/teams-calling/&quot;&gt;technetics.com.au&lt;/a&gt;, licensed under &lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Creative Commons BY-SA 4.0&lt;/a&gt;.&lt;/li&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/757107039702406524/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-integrate-microsoft-teams-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/757107039702406524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/757107039702406524'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-to-integrate-microsoft-teams-with.html' title='How to Integrate Microsoft Teams with SharePoint for Document Management'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip87b8a6V9xSqWZeMpS32cI7v5bM9VIfD4jLwJZ-26gl9uRCl2YmVZv-_7cxydM_0lTM7Pu6xWAeTtJQwJS_DHD6vnATIhUjftrttSi8rc5i8BzznxoiWTVBpnqSqxJZtmoEwOJllxACY-XJKF1QPupB6R09umowZIWEd_DTFm-M66xFt0-wE_7guKIzl9/s72-w640-h324-c/TeamDevices.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-3731531987981584235</id><published>2024-10-04T11:08:00.002+05:30</published><updated>2024-10-04T11:08:22.054+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><title type='text'>Deploying .NET Applications to Microsoft Azure: A Step-by-Step Guide</title><content type='html'>&lt;p&gt;Deploying .NET applications to Microsoft Azure is an efficient way to take advantage of cloud computing capabilities such as scalability, reliability, and cost-effectiveness. This guide will walk you through the step-by-step process of deploying a simple ASP.NET Core application to Azure, covering the essential components needed for a successful deployment.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;Prerequisites&lt;/h2&gt;&lt;p&gt;Before you begin, ensure you have the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Microsoft Azure Account&lt;/strong&gt;: If you don’t have one, you can sign up for a free Azure account.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Visual Studio&lt;/strong&gt;: Install the latest version of Visual Studio with the .NET Core workload.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;.NET SDK&lt;/strong&gt;: Make sure the .NET SDK is installed on your local machine.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Basic knowledge of ASP.NET Core&lt;/strong&gt;: Familiarity with ASP.NET Core is recommended, as this guide will use it as an example.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Step 1: Create an ASP.NET Core Application&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Open Visual Studio&lt;/strong&gt; and select &lt;strong&gt;Create a new project&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Choose &lt;strong&gt;ASP.NET Core Web Application&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Name your project (e.g., &lt;code&gt;MyAzureApp&lt;/code&gt;), select a location, and click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;In the next dialog, choose &lt;strong&gt;Web Application (Model-View-Controller)&lt;/strong&gt; or &lt;strong&gt;Web Application&lt;/strong&gt; (for Razor Pages), depending on your preference, and click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Step 2: Build and Test Your Application Locally&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;Run your application locally to ensure it is working correctly. Press &lt;code&gt;F5&lt;/code&gt; or select &lt;strong&gt;Debug &amp;gt; Start Debugging&lt;/strong&gt; in Visual Studio.&lt;/li&gt;&lt;li&gt;Ensure that the application behaves as expected by navigating through its features.&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Step 3: Prepare Azure Environment&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Log in to the Azure Portal&lt;/strong&gt;: Navigate to &lt;a href=&quot;https://portal.azure.com&quot; rel=&quot;noopener&quot; target=&quot;_new&quot;&gt;https://portal.azure.com&lt;/a&gt; and log in with your credentials.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a Resource Group&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Click on &lt;strong&gt;Resource groups&lt;/strong&gt; in the left navigation pane.&lt;/li&gt;&lt;li&gt;Click &lt;strong&gt;+ Create&lt;/strong&gt; and fill in the details such as the resource group name and region. Click &lt;strong&gt;Review + Create&lt;/strong&gt; and then &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create an App Service&lt;/strong&gt;:&lt;/p&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Click on &lt;strong&gt;Create a resource&lt;/strong&gt; in the top left corner.&lt;/li&gt;&lt;li&gt;Search for &lt;strong&gt;App Service&lt;/strong&gt; and select it.&lt;/li&gt;&lt;li&gt;Click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Fill out the basic settings:&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Subscription&lt;/strong&gt;: Select your subscription.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Resource Group&lt;/strong&gt;: Select the resource group you created.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Name&lt;/strong&gt;: Enter a unique name for your app (this will be part of the URL).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Publish&lt;/strong&gt;: Choose &lt;strong&gt;Code&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Runtime stack&lt;/strong&gt;: Select &lt;code&gt;.NET 6&lt;/code&gt; (or the version you are using).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Region&lt;/strong&gt;: Choose the region closest to your users.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Click &lt;strong&gt;Next&lt;/strong&gt; until you reach the &lt;strong&gt;Review + Create&lt;/strong&gt; step, and then click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixcamNpvVCrm1jia9JopOqq-QEh3_SCyKhlwl1fNjTmrzyJ7fMVhDzQwz2g4vAPdkHH8A23JcssilYWhyKC94t5svvk-4jbhFmbBqXF5CTMxef8bz9BONzsM8WmPpL8ojoiJm_nqvDMQQZE1m3KrgdQpBUYIED5oSORzOOXDkllU1miAfnBB5joBe3_BxJ/s1280/internet-technology-computer-display-1089440.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixcamNpvVCrm1jia9JopOqq-QEh3_SCyKhlwl1fNjTmrzyJ7fMVhDzQwz2g4vAPdkHH8A23JcssilYWhyKC94t5svvk-4jbhFmbBqXF5CTMxef8bz9BONzsM8WmPpL8ojoiJm_nqvDMQQZE1m3KrgdQpBUYIED5oSORzOOXDkllU1miAfnBB5joBe3_BxJ/w640-h426/internet-technology-computer-display-1089440.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;Step 4: Publish Your Application to Azure&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Open Your Project in Visual Studio&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Right-click the project in the Solution Explorer and select &lt;strong&gt;Publish&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;In the Publish dialog:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Choose &lt;strong&gt;Azure&lt;/strong&gt; as the target.&lt;/li&gt;&lt;li&gt;Select &lt;strong&gt;Azure App Service (Windows)&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Select your existing App Service (the one you created in Step 3) and click &lt;strong&gt;Finish&lt;/strong&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Configure Publish Settings&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Click &lt;strong&gt;Publish&lt;/strong&gt; in the Publish dialog.&lt;/li&gt;&lt;li&gt;Visual Studio will build your project and publish it to Azure.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitor the Output&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Once the publishing process is complete, Visual Studio will display the status. You should see a message indicating a successful deployment.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Step 5: Access Your Deployed Application&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to your App Service&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Go back to the Azure Portal and select your App Service.&lt;/li&gt;&lt;li&gt;Click on the &lt;strong&gt;URL&lt;/strong&gt; link to open your deployed application in a new browser tab.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verify Functionality&lt;/strong&gt;: Test your application to ensure it works as expected in the Azure environment.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Step 6: Configure Application Settings&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Environment Variables&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Go to your App Service in the Azure Portal.&lt;/li&gt;&lt;li&gt;Click on &lt;strong&gt;Configuration&lt;/strong&gt; in the left menu.&lt;/li&gt;&lt;li&gt;Here you can set application settings and connection strings.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scaling Options&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Click on &lt;strong&gt;Scale Up (App Service plan)&lt;/strong&gt; to change the pricing tier or scale settings based on your needs.&lt;/li&gt;&lt;li&gt;You can also configure autoscaling under &lt;strong&gt;Scale Out (App Service plan)&lt;/strong&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Step 7: Monitor and Troubleshoot&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Application Insights&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;To monitor the performance of your application, consider enabling &lt;strong&gt;Application Insights&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Go to your App Service and click on &lt;strong&gt;Application Insights&lt;/strong&gt; to configure it.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logs&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Access the logs by navigating to &lt;strong&gt;Log stream&lt;/strong&gt; under the Monitoring section of your App Service.&lt;/li&gt;&lt;li&gt;This helps you troubleshoot issues by viewing live logs of your application.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Step 8: Continuous Deployment (Optional)&lt;/h2&gt;&lt;p&gt;To set up continuous deployment from a source control system (like GitHub or Azure DevOps):&lt;/p&gt;&lt;ol&gt;&lt;li&gt;In the Azure Portal, go to your App Service.&lt;/li&gt;&lt;li&gt;Under &lt;strong&gt;Deployment Center&lt;/strong&gt;, select the source control option (e.g., GitHub).&lt;/li&gt;&lt;li&gt;Follow the prompts to authenticate and select the repository and branch you want to deploy from.&lt;/li&gt;&lt;li&gt;Configure the build settings and click &lt;strong&gt;Finish&lt;/strong&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Deploying .NET applications to Microsoft Azure is a straightforward process that can greatly enhance your application’s capabilities. With Azure’s scalable infrastructure and a wealth of tools, you can easily manage, monitor, and optimize your applications. By following this guide, you should now be able to successfully deploy and manage your .NET applications in the cloud. Whether you are developing a small web app or a large enterprise solution, Azure offers the resources to meet your needs. Happy coding!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/3731531987981584235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/deploying-net-applications-to-microsoft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3731531987981584235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3731531987981584235'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/deploying-net-applications-to-microsoft.html' title='Deploying .NET Applications to Microsoft Azure: A Step-by-Step Guide'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixcamNpvVCrm1jia9JopOqq-QEh3_SCyKhlwl1fNjTmrzyJ7fMVhDzQwz2g4vAPdkHH8A23JcssilYWhyKC94t5svvk-4jbhFmbBqXF5CTMxef8bz9BONzsM8WmPpL8ojoiJm_nqvDMQQZE1m3KrgdQpBUYIED5oSORzOOXDkllU1miAfnBB5joBe3_BxJ/s72-w640-h426-c/internet-technology-computer-display-1089440.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-5672064218728310929</id><published>2024-10-03T18:16:00.007+05:30</published><updated>2024-10-04T11:09:17.016+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="vb.net"/><category scheme="http://www.blogger.com/atom/ns#" term="vb6"/><title type='text'>Reminiscing the Old Days of VB.NET</title><content type='html'>&lt;p&gt;The early 2000s marked a major shift in Microsoft&#39;s programming language landscape with the introduction of the .NET framework. At the time, Visual Basic (VB) was one of the most popular languages, particularly in the enterprise and desktop development worlds. When Microsoft transitioned from VB6 to VB.NET, the community was divided. VB.NET was designed to be a modernized version of Visual Basic, adopting object-oriented principles and leveraging the capabilities of the .NET framework. However, this transition also presented challenges for long-time VB developers who had to adapt to the new language’s stricter syntax and rules. Many developers found the learning curve steep, and some felt that VB.NET lost the simplicity that made VB6 so popular.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;The Rise of C#&lt;/h3&gt;&lt;p&gt;While VB.NET was intended to modernize Visual Basic, C# emerged as a competitor from within Microsoft’s own ranks. Introduced alongside VB.NET as part of the .NET framework, C# was seen as Microsoft&#39;s answer to Java. Its syntax was cleaner, more intuitive for those familiar with modern programming practices, and more appealing to younger developers. C# also gained favor among developers who worked in object-oriented programming languages like C++ or Java, as its structure was more familiar to them.&lt;/p&gt;&lt;p&gt;As enterprises and developers transitioned to .NET, C# began to outpace VB.NET for several key reasons:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stronger Focus on Object-Oriented Design&lt;/strong&gt;: While VB.NET adopted object-oriented programming (OOP) principles, C# was designed with OOP at its core, making it more appealing for large-scale applications.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Developer Community and Ecosystem&lt;/strong&gt;: The community around C# grew faster, with a greater focus on modern web and enterprise application development. It quickly became the preferred language for new projects.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Industry Perception&lt;/strong&gt;: C# was perceived as the future-facing language, while VB.NET was often seen as an evolution of an older technology. This perception fueled its popularity, especially as startups and new companies adopted C# for its scalability and modernity.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;Key Differences and Developer Sentiments&lt;/h3&gt;&lt;p&gt;For VB developers transitioning to VB.NET, the changes were significant. Some of the frustrations included:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Stricter Syntax&lt;/strong&gt;: VB.NET introduced a more rigid, object-oriented structure compared to the forgiving nature of VB6. This alienated many who preferred VB for its simplicity.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;New Features to Learn&lt;/strong&gt;: While VB.NET allowed for more powerful applications, its introduction of new features like exception handling, inheritance, and polymorphism required developers to adjust their coding styles.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;On the other hand, C# was a blank slate for many developers. It wasn’t tied to previous expectations, which made it easier for newer developers to embrace without comparing it to past experiences.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9b2zLUFJGMh3qkwO4n9bc07S6Y4qwu7-3zxB_Qu3BoU72gcFmXrjjsbRNEukzsOGvFyd4tZKvbFwuo-q2qBJy3h9OOu6E8j-5EKain8HCqm16e1SvTVZSPgu3kPud65OPuK1Tmu3EBCEli6hQuhjIaPdXYJcHq0subNicTp2HqhR4rNUfOOTZ3SEoCIvA/s1280/computer-monitor-coding-programming-2194062.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9b2zLUFJGMh3qkwO4n9bc07S6Y4qwu7-3zxB_Qu3BoU72gcFmXrjjsbRNEukzsOGvFyd4tZKvbFwuo-q2qBJy3h9OOu6E8j-5EKain8HCqm16e1SvTVZSPgu3kPud65OPuK1Tmu3EBCEli6hQuhjIaPdXYJcHq0subNicTp2HqhR4rNUfOOTZ3SEoCIvA/w640-h426/computer-monitor-coding-programming-2194062.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;The Decline of VB.NET&lt;/h3&gt;&lt;p&gt;As the 2000s progressed, C# became the dominant language in the .NET ecosystem. The reasons for VB.NET&#39;s decline included:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Fewer Updates&lt;/strong&gt;: Microsoft shifted its focus to C#, making VB.NET updates less frequent and less impactful.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Community and Ecosystem Growth&lt;/strong&gt;: C# benefitted from stronger support from the developer community, with more libraries, tutorials, and tools being developed specifically for C# projects.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Perception Shift&lt;/strong&gt;: VB.NET became associated with legacy systems, while C# was seen as the go-to language for modern development.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Remnants of VB.NET Today&lt;/h3&gt;&lt;p&gt;Though VB.NET is still supported within the .NET ecosystem, its role has largely been reduced to maintaining legacy applications. Most new projects within the .NET framework are now developed in C#. However, VB.NET still holds a special place in the hearts of many developers who built their careers on earlier versions of Visual Basic.&lt;/p&gt;&lt;p&gt;The transition from VB.NET to C# symbolizes a broader shift in the development world, where simplicity gave way to powerful, scalable, and modern programming practices. For those who remember the old days of VB.NET, it represents an era where Microsoft sought to bridge the gap between simplicity and modernity, but ultimately, the future belonged to C#. Today, VB.NET is remembered fondly, but C# reigns supreme in the .NET world, carrying the legacy of that transition into the future of software development.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/5672064218728310929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/reminiscing-old-days-of-vbnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/5672064218728310929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/5672064218728310929'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/reminiscing-old-days-of-vbnet.html' title='Reminiscing the Old Days of VB.NET'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9b2zLUFJGMh3qkwO4n9bc07S6Y4qwu7-3zxB_Qu3BoU72gcFmXrjjsbRNEukzsOGvFyd4tZKvbFwuo-q2qBJy3h9OOu6E8j-5EKain8HCqm16e1SvTVZSPgu3kPud65OPuK1Tmu3EBCEli6hQuhjIaPdXYJcHq0subNicTp2HqhR4rNUfOOTZ3SEoCIvA/s72-w640-h426-c/computer-monitor-coding-programming-2194062.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-7173607524523590125</id><published>2024-10-02T17:53:00.001+05:30</published><updated>2024-10-04T11:13:06.396+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="alternativeto"/><title type='text'>How User Contributions Shape Recommendations on AlternativeTo.net</title><content type='html'>&lt;p&gt;In the ever-expanding landscape of software solutions, finding the right tools can be overwhelming. Enter &lt;strong&gt;AlternativeTo.net&lt;/strong&gt;, a platform dedicated to helping users discover software alternatives based on community recommendations. What sets AlternativeTo apart is its reliance on user contributions, making it a unique blend of crowdsourced knowledge and tech expertise. This article delves into how user contributions shape the recommendations on AlternativeTo.net and why they matter.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;At the heart of AlternativeTo.net is a vibrant community of users who actively participate by submitting software suggestions and providing ratings and reviews. This feedback mechanism not only enriches the platform but also creates a dynamic database of software options that reflect the preferences and needs of real users.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Submitting Software Suggestions&lt;/strong&gt;: Users can recommend alternatives to existing software, ensuring that the database continually evolves. This process democratizes the information available, as anyone can contribute their insights based on personal experiences.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rating and Reviewing&lt;/strong&gt;: Each alternative listed on the platform comes with user ratings and reviews. These contributions help others gauge the reliability and effectiveness of a software solution. A higher rating often indicates a well-regarded option that has met the expectations of its users.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The collaborative nature of AlternativeTo.net fosters a sense of community among tech enthusiasts. This collective effort is crucial for curating content that is not only relevant but also trustworthy.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;User-Generated Content&lt;/strong&gt;: The platform relies heavily on user-generated content to maintain its extensive database. This includes everything from basic software descriptions to detailed reviews that highlight specific features, usability, and potential drawbacks. As users share their insights, they help others make informed decisions.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quality Control&lt;/strong&gt;: Although the content is user-generated, AlternativeTo.net employs mechanisms to ensure quality. Popular alternatives tend to be the ones that receive the most community engagement, leading to a natural selection of the best tools. Users can upvote alternatives, signaling their approval and increasing visibility for well-regarded options.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwaMW2_FbLrWNMFLi4Z4uL6-zjKNt_MrhfoJRq6LT9H7go2rNdFyPIgxr6KfoD2TzKFCt3mfLmSCh7-ER7A4HQbRYjSYl3B1uem8veuYdGUV90pL93MwIgNZYSjo8jr5nrqBLpW5lef64RQfUDl1DdS99yKaewqoCqKoP28H-xH244R9_x8_XM2voaW5DJ/s2048/pexels-photo-433639.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1365&quot; data-original-width=&quot;2048&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwaMW2_FbLrWNMFLi4Z4uL6-zjKNt_MrhfoJRq6LT9H7go2rNdFyPIgxr6KfoD2TzKFCt3mfLmSCh7-ER7A4HQbRYjSYl3B1uem8veuYdGUV90pL93MwIgNZYSjo8jr5nrqBLpW5lef64RQfUDl1DdS99yKaewqoCqKoP28H-xH244R9_x8_XM2voaW5DJ/w640-h426/pexels-photo-433639.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;By emphasizing user contributions, AlternativeTo.net enhances the discoverability of software options that might otherwise go unnoticed. This is particularly valuable for niche software solutions that serve specific needs but lack marketing resources.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Spotlighting Lesser-Known Alternatives&lt;/strong&gt;: User contributions can bring attention to lesser-known software alternatives that provide unique features or better pricing than mainstream options. This helps diversify the software landscape and offers users more choices.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tailoring Recommendations&lt;/strong&gt;: The platform’s algorithm considers user interactions, tailoring recommendations based on collective user preferences. This means that users are more likely to encounter software that aligns with their needs and interests, thanks to the input of fellow community members.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The influence of user contributions on AlternativeTo.net underscores the importance of collective knowledge in navigating the complex world of software solutions. By participating in this community-driven platform, users not only enhance the reliability of the recommendations but also empower others in their search for the right tools. In an age where software options abound, AlternativeTo.net stands out as a testament to the power of collaboration, proving that when users come together, they can significantly improve the software discovery process for everyone.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/7173607524523590125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-user-contributions-shape.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/7173607524523590125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/7173607524523590125'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2024/10/how-user-contributions-shape.html' title='How User Contributions Shape Recommendations on AlternativeTo.net'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwaMW2_FbLrWNMFLi4Z4uL6-zjKNt_MrhfoJRq6LT9H7go2rNdFyPIgxr6KfoD2TzKFCt3mfLmSCh7-ER7A4HQbRYjSYl3B1uem8veuYdGUV90pL93MwIgNZYSjo8jr5nrqBLpW5lef64RQfUDl1DdS99yKaewqoCqKoP28H-xH244R9_x8_XM2voaW5DJ/s72-w640-h426-c/pexels-photo-433639.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-3830988857149111981</id><published>2021-08-03T12:38:00.005+05:30</published><updated>2021-08-03T12:48:40.625+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ado.net"/><category scheme="http://www.blogger.com/atom/ns#" term="csharp"/><title type='text'>Challenges faced while using ADO.NET while interacting with Database</title><content type='html'>&lt;p&gt;Frankly, I&#39;ve found the ADO.NET&#39;s disconnected database model to be quite a verbose and lengthy process to work with. First, you need to create a Connection object to connect to the database and then corresponding DataAdapter and DataSet objects to deal with each table in that database. For example, assuming just 4 tables in an SQLite table, there will be 1 SQLiteConnection, 4 SQLiteDataAdapter objects and 4 DataSet objects, so total 9 objects just to work with the database! This is perhaps too much to grasp for someone coming from Python or PHP where its much simpler to create a connection and/or cursor object which can then be used to query any given table using a SQL statement.&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIHhtH1fTGF6TIRXNgRw-qt_fU7UhhNtuQ9BBa7V5zopBEe0nkcJPu4JLAuZMLrZTvpI98pdkuHkPgGhCgrhjmDB-FCDY69lDgdgnxkYHCp3UoQsYvtGHNT8UznbT6Sw0pqfC1U6LEhApK/s1280/business-clean-computer-connection-389819.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIHhtH1fTGF6TIRXNgRw-qt_fU7UhhNtuQ9BBa7V5zopBEe0nkcJPu4JLAuZMLrZTvpI98pdkuHkPgGhCgrhjmDB-FCDY69lDgdgnxkYHCp3UoQsYvtGHNT8UznbT6Sw0pqfC1U6LEhApK/s320/business-clean-computer-connection-389819.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Of course, there are ways to solve this problem and make it as seamless as the Python/PHP way. The challenge of low level language like C# or Java is that a programmer has to solve this &quot;making it seamless/reusable/dynamic&quot; problem himself, nothing is served through the runtime as it happens in case of an interpreted language. A typical pattern that can be used to solve this problem is to encapsulate fetching and updating of tables in just one static function which can keep the track of DataAdapters and Connections while the user is free to work with Datasets. And instead of creating an adapter and dataset for every single table, we can just have two dictionaries called &lt;code&gt;adapters&lt;/code&gt; and &lt;code&gt;datasets&lt;/code&gt;! This is the pattern I typically use in my C# projects. Below example uses a SQLite database but should work for just about any.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;private static SQLiteConnection conn = null;
private static Dictionary&amp;lt;string, SQLiteDataAdapter&amp;gt; adapters 
	= new Dictionary&amp;lt;string, SQLiteDataAdapter&amp;gt;();
private static Dictionary&amp;lt;string, DataSet&amp;gt; datasets 
	= new Dictionary&amp;lt;string, DataSet&amp;gt;();

public static DataSet openTable(string tableName) {
    if (conn == null) { //initialize connection if not already
        var connstr = @&quot;Data Source=db.sqlite3;Version=3;New=True;Compress=True&quot;;
        conn = new SQLiteConnection(connstr); 
    }
    //initialize adapter and dataset if not already:
    if (!adapters.Keys.Contains(tableName))
    {
        adapters.Add(tableName,
        new SQLiteDataAdapter(&quot;select * from &quot; + tableName, conn));
        datasets.Add(tableName, new DataSet());
        adapters[tableName].Fill(datasets[tableName]);
    }
    return datasets[tableName];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The code becomes much simpler and easier, almost as seamless as a dynamic language such as Python! You can place this in a static class called &lt;code&gt;util&lt;/code&gt; or something (that&#39;s what I typically call it!) and then other parts of your code can just call &lt;code&gt;util.openTable(&#39;foo&#39;)&lt;/code&gt; whenever they want to work with a database table.&lt;/p&gt;

&lt;p&gt;Now the question arises as to what about saving or pushing the DataSet changes back to the table? No problem, that is also very easy once you&#39;ve already done this groundwork!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public static int saveTable(DataSet ds) {
    DataSet changes = ds.GetChanges();
    SQLiteDataAdapter da = adapters[ds.Tables[0].TableName];
    if (changes == null) return 0;
    SQLiteCommandBuilder scb = new SQLiteCommandBuilder();
    scb.ConflictOption = ConflictOption.CompareRowVersion;
    int cnt = da.Update(changes, ds.Tables[0].TableName);
    ds.AcceptChanges();
    return cnt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We just check if there are any changes in the DataSet and if changes are found, we simply call the DataAdapter&#39;s update method and pass to it the corresponding changed DataSet!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/3830988857149111981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2021/08/adonet-challenges-faced-while-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3830988857149111981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3830988857149111981'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2021/08/adonet-challenges-faced-while-using.html' title='Challenges faced while using ADO.NET while interacting with Database'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIHhtH1fTGF6TIRXNgRw-qt_fU7UhhNtuQ9BBa7V5zopBEe0nkcJPu4JLAuZMLrZTvpI98pdkuHkPgGhCgrhjmDB-FCDY69lDgdgnxkYHCp3UoQsYvtGHNT8UznbT6Sw0pqfC1U6LEhApK/s72-c/business-clean-computer-connection-389819.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-4262982849272966127</id><published>2013-04-16T00:44:00.005+05:30</published><updated>2024-10-11T13:14:38.116+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net framework"/><category scheme="http://www.blogger.com/atom/ns#" term="c sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="multi-threading"/><title type='text'>7 Key Reasons Developers Love C# Programming</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Multithreading
 support in C#&lt;/u&gt;&lt;/h2&gt;&lt;div&gt;While there are many advantages of the language, C# multithreading features is what tops my list. The
 reason is that the threading mechanism is so much intuitive and easier to
 implement than many other languages like C++ or even java.&lt;/div&gt;&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
What other language
 allows you to start a thread, then pause it for 5 seconds, then wait
 for 7 seconds for it to complete, then instantly terminate it if it
 doesn&#39;t complete and implement this in just 4 lines of code!&lt;br /&gt;
&lt;script class=&quot;brush: csharp&quot; type=&quot;syntaxhighlighter&quot;&gt;
private void startThread()
{
    Thread fooThread = new Thread(foo);
    fooThread.Start(); Thread.Sleep(5000); fooThread.Suspend();
    fooThread.Join(7000);
    if (fooThread.IsAlive) fooThread.Abort(); 
}
&lt;/script&gt;
&lt;/div&gt;
&lt;br /&gt;
Other
multithreading features like mutex, lock, Monitor and Event are just
as intuitive to  use. The end result is that even the average
programmer who doesn&#39;t have an iron grip  over thread programming ends up coding a
pretty decent multithreaded solution in C#.&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Rich Framework Library&lt;/u&gt;&lt;/h2&gt;&lt;div class=&quot;western&quot;&gt;Though theoretically C# is a language in its own right, it is almost inseparable with the .NET Framework
 that it is so closely integrated with. Yet another reason I prefer
 C# and .NET so much is that it comes pre-bundled with such a
 comprehensive library (Framework Class Library), that you hardly
 ever need to look elsewhere to implement any feature you want – be
 it anything:&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
Networking/Socket
  programming (System.Net and System.Net.Sockets)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
File I/O
  (System.IO)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
Graphics
  (System.Drawing)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
Multithreading
  (System.Threading)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
Remoting
  (System.Runtime.Remoting)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
Database
  interaction (System.Data, System.Data.SqlClient)&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
Moreover, the library
  integrates so well with Windows environment that you never have to
  worry about performance as it happens in case of Java. You can
  concentrate entirely on writing your business-logic without
  worrying about the underlying low-level plumbing of these things which .NET does seamlessly for you.&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 style=&quot;margin-bottom: 0cm; text-align: left;&quot;&gt;&lt;u&gt;Elegance in
 language&lt;/u&gt;&lt;/h2&gt;&lt;p style=&quot;margin-bottom: 0cm; text-align: left;&quot;&gt;Especially for someone who admires the
 compactness and preciseness of the C family of languages and at the same time, is
 also familiar with the rapid development cycles of Visual Basic
 language, C# offers an excellent blend of the two worlds. In fact,
 this was the very purpose when C# was initially designed in 1999. To
 bring the elegant syntax of C++ to VB programmers, and to bring the
 RAD nature of VB to C++.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Delegates&lt;/u&gt;&lt;/h2&gt;&lt;div&gt;Though not many people are very fond of this feature, in my
 humble opinion, the language allows you to do almost everything you
 can do with pointers in C/C++ without the corresponding risk
 associated with referencing/dereferencing with pointers.  With
 delegates, you can define a simple prototype for a function, and
 then use it as a custom datatype that points to any actual function
 that matches the prototype.&lt;br /&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Automatic
 Memory Management&lt;/u&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;Though it is not a feature of C# language
 per se, I cannot overstate the benefits of automatic memory management in C# nevertheless. I still
 remember how tedious it is to manage memory in C language using
 malloc, realloc and dealloc from my college days. Though the
 situation improved with Visual Basic, the solution wasn&#39;t quite
 robust since each VB program ran in its own unmanaged process and
 any loopholes in a single part of your program can bring the whole
 thing crashing down. Such things no longer happen in C#. The CLR
 takes care of allocating memory to your objects and there is a
 garbage-collector which automatically disposes any objects you
 forgot to set as null. So graceful!! (Though a caveat is that this
 grace isn&#39;t quite available when dealing with COM components and you
 have to manually call Marshal.ReleaseComObject()
 to
 dispose your COM objects, but thats another story).&lt;br /&gt;
&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Networking,
 Sockets and Stuff&lt;/u&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;At work, I have to deal with several networking projects that
 typically involve socket programming – sending/receiving a bunch
 of raw binary data on specific ports using TCP/UDP sockets. I can
 never imagine the situation if there were no C# to help by providing
 its feature-filled classes in System.Net and System.Net.Sockets
 namespaces that do the job seamlessly. Here are some of the classes that I frequently use:&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. &lt;b&gt;HttpWebRequest&lt;/b&gt; - An easy to use wrapper that handles all the low level plumbing required to create an Http web request. All you have to provide is the url as input.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 2. &lt;b&gt;HttpWebResponse &lt;/b&gt;- Once the request is created, calling GetReponse() on the request object will return HttpWebResponse which is equally helpful. This object has GetResponseStream() which gives a NetworkStream object from which we can seamlessly read the received data in whatever format we like viz. raw-bytes,&amp;nbsp; strings, xml, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 3. &lt;b&gt;TcpClient&lt;/b&gt;, &lt;b&gt;TcpServer&lt;/b&gt;, &lt;b&gt;Socket &lt;/b&gt;- Sometimes, the scenario is not as simple as sending a simple web request and reading the response. If you want to handle all the low level details yourself, then these three classes will be the most helpful to you.&lt;br /&gt;
&lt;br /&gt;
Lately, I&#39;m working on an opensource project called &lt;a href=&quot;https://scavenger.codeplex.com/&quot; target=&quot;_blank&quot;&gt;scavenger&lt;/a&gt;, an internet download manager coded in C#. I&#39;ve made extensive use of all these classes in that.&amp;nbsp; &lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnmcLyIitAX7Ck7UElQyFxnX1-XCIBJ2OsTtSqAT7g4T7YZHNLncoKF8TywzeGaYSHX2eT4HgAohN2Llu3_upiFFgUgRIol8nyquZHv0EXgvqUCMD1mvjIi81WioGp94hAKCf9WYBxukxX7WALSX3rN-UDU7ekV-L8hjP9rNDVfgc8HMQNSPv61NCXPmUL/s1280/computer-monitor-coding-programming-2194062.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnmcLyIitAX7Ck7UElQyFxnX1-XCIBJ2OsTtSqAT7g4T7YZHNLncoKF8TywzeGaYSHX2eT4HgAohN2Llu3_upiFFgUgRIol8nyquZHv0EXgvqUCMD1mvjIi81WioGp94hAKCf9WYBxukxX7WALSX3rN-UDU7ekV-L8hjP9rNDVfgc8HMQNSPv61NCXPmUL/w640-h426/computer-monitor-coding-programming-2194062.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;WinForms,
 WPF and Stuff&lt;/u&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;Using WinForms is a breeze if you have ever developed anything in
 Visual Basic 6 or a similar tool. The most useful thing about
 WinForms is its rich set of .NET controls ranging from TreeViews,
 ListViews, Progressbars, Toolbars, Split containers, tabbed
 containers, layout panels – you name it. GUI development was never
 that easier. I haven&#39;t used WPF quite, but from what I&#39;ve heard, I
 surmise that it must be same there as well.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/4262982849272966127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2013/04/7-reasons-im-fond-of-c-programming.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/4262982849272966127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/4262982849272966127'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2013/04/7-reasons-im-fond-of-c-programming.html' title='7 Key Reasons Developers Love C# Programming'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnmcLyIitAX7Ck7UElQyFxnX1-XCIBJ2OsTtSqAT7g4T7YZHNLncoKF8TywzeGaYSHX2eT4HgAohN2Llu3_upiFFgUgRIol8nyquZHv0EXgvqUCMD1mvjIi81WioGp94hAKCf9WYBxukxX7WALSX3rN-UDU7ekV-L8hjP9rNDVfgc8HMQNSPv61NCXPmUL/s72-w640-h426-c/computer-monitor-coding-programming-2194062.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-6381377226591133803</id><published>2013-02-10T18:10:00.001+05:30</published><updated>2021-08-12T18:59:11.319+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="listbox"/><category scheme="http://www.blogger.com/atom/ns#" term="sendmessage"/><category scheme="http://www.blogger.com/atom/ns#" term="tricks"/><category scheme="http://www.blogger.com/atom/ns#" term="vb6"/><category scheme="http://www.blogger.com/atom/ns#" term="windows api"/><title type='text'>Some VB6 Tricks</title><content type='html'>Though Visual Basic 6 has started
getting lost in antiquity since the advent of .NET, we do know there
are still zillions of VB6 programs in existence, with medium to high
complexity. They are not migrated to C# or VB.NET and are maintained
in their current state.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
This may be due to several reasons, the
primary being the high cost involved in migrating to .NET platform.
Given below are a few tips and tricks to better the user experience
that I’ve come across during my programming endeavors while dealing
with VB6:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;b&gt;[1] Adding horizontal scrollbar
to a list box:&lt;/b&gt; The standard listbox control provided by VB6
pretty much serves our purpose when we want to show a list of
possible values to a user from which she can select one. However,
there is one slight glitch: There is no horizontal scrollbar in it.
If the number of list items increase beyond the visible area of the
listbox control, then yes, we automatically get a vertical scrollbar
to scroll. But when the text width is too much, the user cannot read
the entire text, you get something like this:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZmdSqjvAHku0no-5LPytxYQ4sgNDaMBc2NlHJGV73684ehp3NcmU4sT_uWI2mQdJQF0X0-O9dyvZLFI65IzsmIC_D4xVU89c8mvTHUWFOgVeFcbepXiYUGpsDhBf3w3pzAMey2CsbajXn/s1600/vb6tips.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZmdSqjvAHku0no-5LPytxYQ4sgNDaMBc2NlHJGV73684ehp3NcmU4sT_uWI2mQdJQF0X0-O9dyvZLFI65IzsmIC_D4xVU89c8mvTHUWFOgVeFcbepXiYUGpsDhBf3w3pzAMey2CsbajXn/s1600/vb6tips.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
In the above screen there is a
vertical, but no horizontal bar. To overcome this limitation, we need
to use a Windows API function called SendMessage(). Windows API is a
powerful method to get access to functionality that VB6 does not
provide out of the box. In order to use the SendMessage() function,
all you have to do is declare this function at the top of your VB
Form code:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Option Explicit&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Private Declare
Function SendMessage Lib &quot;user32&quot; _&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Alias
&quot;SendMessageA&quot; (ByVal hwnd As Long, ByVal _&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
wMsg As
Long, ByVal wParam As Long, ByVal lParam As Long) As Long&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Const
LB_SETHORIZONTALEXTENT = &amp;amp;H194&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
Do remember that you only need to
declare this once in your form, though this function may be called at
several places. If you are going to use the function at several
places, then declare it in a global module instead and make it
public. The second declaration beginning with “Const” declares a
constant that comes handy while using this function. Now, let us use
this function by calling it. Typically, this will be inside the
Form_Load event of your form:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Dim x As Long&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Dim s As String&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
x =
TextWidth(List1.List(0) &amp;amp; &quot;  &quot;)&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
If
ScaleMode = vbTwips Then _&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
x =
x / Screen.TwipsPerPixelX  &#39; if twips change to pixels&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, x, 0&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Here, we first
determine the width our horizontal scrollbar will have. This is
determined by the variable x. We assign it the text-width of the
first item in your listbox i.e. List1.List(0). In a real world
application however, you have to make it equal to the widest string
in your listbox. Once you do this, you will have a horizontal
scrollbar in your listbox as shown below:&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfz13ceiuu3qBszYP_hcrCSH6AV7bG84oMsrbnCs0fW2NDYNgThm3OjDwhyphenhypheniTa5Rs67b8NZm6WfrbAjmk_adSow9Js26JPiGaI2LgmBhwW_PebKplxIfBqzO795bEZcBiKK7efl_Ee2aC3/s1600/vb6tipshoriz.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfz13ceiuu3qBszYP_hcrCSH6AV7bG84oMsrbnCs0fW2NDYNgThm3OjDwhyphenhypheniTa5Rs67b8NZm6WfrbAjmk_adSow9Js26JPiGaI2LgmBhwW_PebKplxIfBqzO795bEZcBiKK7efl_Ee2aC3/s1600/vb6tipshoriz.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;b&gt;[2] Adding soft-search facility
to a listbox:&lt;/b&gt; Soft-search is a facility provided by many
applications to instantly show filtered results in a dropdown as you
type. Popular example of this is the google search box that shows
matching search terms in a dropdown as you start typing your search
text. Now, suppose, you want to provide a similar facility in your
VB6&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
Form by providing a textbox control to type and a listbox to
filter the soft-search results. How difficult do you think this would
be? Pretty trivial, I would say, by using the SendMessage() API
function. You already get what the user is typing in the textbox in
the Change() event. All you have to do is call this API function, and
pass the search string and list-box handle as the parameters.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
The API
will automatically find and return the index of the searched string
if found in the Listbox!! Now all you have to do is set the topindex
property of the listbox to that of the value returned by
SendMessage() function:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Private Sub
Text1_Change()&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
Dim i As Integer&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
i =
SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal Text1.Text)&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
If i &amp;lt;&amp;gt; -1
Then&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
List1.TopIndex
= i&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&#39;Else&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
&#39;List1.Selected(&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
End If&lt;/div&gt;
&lt;div style=&quot;line-height: 0.17in; margin-bottom: 0in;&quot;&gt;
End Sub&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2qOMAjqUlqq0BMPsa3AcYC81wrX2TuZz5n4qSzTMRLx73I3qLjP60kev-uEpaHE1BUy7GbRG8PA2jRDHweWHEASPhU45gwpgpqMqQ4AVS0khGl_TwrpAV9P7AC4T3d1i7kal7WPWS1R9P/s1600/softseek.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2qOMAjqUlqq0BMPsa3AcYC81wrX2TuZz5n4qSzTMRLx73I3qLjP60kev-uEpaHE1BUy7GbRG8PA2jRDHweWHEASPhU45gwpgpqMqQ4AVS0khGl_TwrpAV9P7AC4T3d1i7kal7WPWS1R9P/s1600/softseek.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.14in;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/6381377226591133803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2013/02/some-vb6-tricks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/6381377226591133803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/6381377226591133803'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2013/02/some-vb6-tricks.html' title='Some VB6 Tricks'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZmdSqjvAHku0no-5LPytxYQ4sgNDaMBc2NlHJGV73684ehp3NcmU4sT_uWI2mQdJQF0X0-O9dyvZLFI65IzsmIC_D4xVU89c8mvTHUWFOgVeFcbepXiYUGpsDhBf3w3pzAMey2CsbajXn/s72-c/vb6tips.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-2474138614438446438</id><published>2012-02-05T19:43:00.003+05:30</published><updated>2024-10-11T13:19:25.254+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="c sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="graphics"/><category scheme="http://www.blogger.com/atom/ns#" term="vb.net"/><title type='text'>How to convert an image to bytes in .NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
One of the most standard queries I come across in many of the coding forums these days is, how do we convert an image (Image/Bitmap class) in .NET to a byte[] array? The answer to this is very straight forward - a few lines of code in VB.NET or C#:&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB.NET:&lt;/b&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Function CaptureScreen() As Bitmap&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;CAPTURE THE BITMAP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39; Size size is how big an area to capture&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39; pointOrigin is the upper left corner of the area to capture&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim width As Integer =&amp;nbsp; Screen.PrimaryScreen.Bounds.X + Screen.PrimaryScreen.Bounds.Width &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim height As Integer =&amp;nbsp; Screen.PrimaryScreen.Bounds.Y + Screen.PrimaryScreen.Bounds.Height &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim size As Size =&amp;nbsp; New Size(width,height) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pointOfOrigin As Point =&amp;nbsp; New Point(0,0) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim desktopBitmap As Bitmap =&amp;nbsp; New Bitmap(size.Width,size.Height) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Imports (Graphics graphics = Graphics.FromImage(desktopBitmap))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphics.CopyFromScreen(pointOfOrigin,New Point(0,0),size)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;CAPTURE CURSOR&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim cursorX As Integer = 0,cursorY As Integer =&amp;nbsp; 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim cursorBitmap As Bitmap =&amp;nbsp; CaptureCursor( cursorX,ref cursorY) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;MERGE THE CURSOR INTO DESKTOP BITMAP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not cursorBitmap Is Nothing Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim g As Graphics&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim r As Rectangle&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r = New Rectangle(cursorX, cursorY, cursorBitmap.Width, cursorBitmap.Height)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g = Graphics.FromImage(desktopBitmap)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.DrawImage(cursorBitmap, r)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.Flush()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return desktopBitmap&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return desktopBitmap&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;C#:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;code&gt;&lt;/code&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Bitmap CaptureScreen()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //CAPTURE THE BITMAP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Size size is how big an area to capture&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // pointOrigin is the upper left corner of the area to capture&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int width = Screen.PrimaryScreen.Bounds.X + Screen.PrimaryScreen.Bounds.Width;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int height = Screen.PrimaryScreen.Bounds.Y + Screen.PrimaryScreen.Bounds.Height;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Size size = new Size(width, height);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point pointOfOrigin = new Point(0, 0);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Bitmap desktopBitmap = new Bitmap(size.Width, size.Height);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (Graphics graphics = Graphics.FromImage(desktopBitmap))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphics.CopyFromScreen(pointOfOrigin, new Point(0, 0), size);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //CAPTURE CURSOR&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int cursorX=0, cursorY=0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Bitmap cursorBitmap = CaptureCursor(ref cursorX,ref cursorY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //MERGE THE CURSOR INTO DESKTOP BITMAP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (cursorBitmap != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Graphics g;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rectangle r;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r = new Rectangle(cursorX, cursorY, cursorBitmap.Width, cursorBitmap.Height);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g = Graphics.FromImage(desktopBitmap);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.DrawImage(cursorBitmap, r);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.Flush();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return desktopBitmap;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return desktopBitmap;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1adVtCoXSoEIcm0zKIF-th6H6txLMWQTQ17JD2xq5ITA3NE4__E9AkaD5VXt8k3j7ujA1HndinttoEMHLrqcdqzJEjNerrUOvbISjoYOD1aruf1zDa-s04mQqVDHhykNCmVlAnBJ-BunPLYfX5wzfFrJ3gjk0M0_dT3rCkg8wu1JgKovIZmuprISRprm4/s1280/internet-technology-computer-display-1089440.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1adVtCoXSoEIcm0zKIF-th6H6txLMWQTQ17JD2xq5ITA3NE4__E9AkaD5VXt8k3j7ujA1HndinttoEMHLrqcdqzJEjNerrUOvbISjoYOD1aruf1zDa-s04mQqVDHhykNCmVlAnBJ-BunPLYfX5wzfFrJ3gjk0M0_dT3rCkg8wu1JgKovIZmuprISRprm4/w640-h426/internet-technology-computer-display-1089440.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Do note that the parameter passed to this function should be an object of &lt;b&gt;System.Drawing.Bitmap&lt;/b&gt; type. If you have an object of Image type instead, you may convert it to Bitmap by doing this:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;Graphics.FromImage(imageObject)&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/2474138614438446438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2012/02/how-to-convert-image-to-bytes-in-net.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/2474138614438446438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/2474138614438446438'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2012/02/how-to-convert-image-to-bytes-in-net.html' title='How to convert an image to bytes in .NET'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1adVtCoXSoEIcm0zKIF-th6H6txLMWQTQ17JD2xq5ITA3NE4__E9AkaD5VXt8k3j7ujA1HndinttoEMHLrqcdqzJEjNerrUOvbISjoYOD1aruf1zDa-s04mQqVDHhykNCmVlAnBJ-BunPLYfX5wzfFrJ3gjk0M0_dT3rCkg8wu1JgKovIZmuprISRprm4/s72-w640-h426-c/internet-technology-computer-display-1089440.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-3523168614309187820</id><published>2012-01-17T08:02:00.001+05:30</published><updated>2024-10-11T13:20:38.023+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net framework"/><category scheme="http://www.blogger.com/atom/ns#" term="c sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><category scheme="http://www.blogger.com/atom/ns#" term="vb.net"/><title type='text'>How to code efficiently in a .NET language</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here are some techniques you may apply in your quest to become a better .NET coder:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[1] Leverage the power of industry-standard tools.&lt;/b&gt; There exist many proven tools to help you with various programming needs.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;Some,
 like the the Redgate reflector is a commercial one (with a 
limited-feature free trial version available). It is used to reconstruct
 the lost source code (in VB.NET/C#) from the .NET assembly (exe/dll).&lt;br /&gt;
&lt;br /&gt;
On
 the other hand, a NUnit (used for unit testing .NET components) and 
NANT (build tool to automate build process of .NET sources) are 
opensource and 100% free. A fairly comprehensive list of all such tools 
are available here:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://prahladyeri.wordpress.com/2013/01/25/some-free-tools-to-help-you-develop-better-net-solutions/&quot; target=&quot;_blank&quot;&gt;List of free and opensource .NET tools.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[2] Follow proper naming conventions for variables and constants.&lt;/b&gt; A good naming convention has several advantages such as providing meta-data about the variable or function name, promotes consistency and readability within a team and provides better understanding in case of code-reuse.&lt;br /&gt;
For variables and type names, Microsoft recommends a pascal casing convention where the first letter of the name is capitalized and the rest is in proper case (example &quot;ToString&quot;, &quot;Red&quot;, &quot;BackColor&quot;, &quot;ForeColor&quot;, etc.). For parameter names, Microsoft recommends camel casing convention where the first letter of the name is small and the rest is proper case (example &quot;toString&quot;, &quot;red&quot;, &quot;backColor&quot;, &quot;foreColor&quot;, etc.)&lt;br /&gt;
&lt;br /&gt;
Microsoft also has recommendations for naming Assemblies &amp;amp; DLLs,&amp;nbsp; Namespaces, Struct Types, etc. For more information on this, see&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms229042.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt; Microsoft .NET Design guidelines for class libraries&lt;/a&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwJxZAwRmn64bkjPgA_gXZIiuhlxdnXEGzj-sF1pyZC78EyZt_rvNRCFHgPPyBUtgKCpVUPzu14WYy6AUFEfQfqkU-FN91S54IBeKK1SZAc7MxTg417VNJS3-5Z0DfEHyX3ekyy-SMOUaYe1s9K7pDutTz6Yk7iNGLUNxMNUDgTDDFoB4ka-4q5AgDlQPG/s1280/computer-monitor-coding-programming-2194062.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;853&quot; data-original-width=&quot;1280&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwJxZAwRmn64bkjPgA_gXZIiuhlxdnXEGzj-sF1pyZC78EyZt_rvNRCFHgPPyBUtgKCpVUPzu14WYy6AUFEfQfqkU-FN91S54IBeKK1SZAc7MxTg417VNJS3-5Z0DfEHyX3ekyy-SMOUaYe1s9K7pDutTz6Yk7iNGLUNxMNUDgTDDFoB4ka-4q5AgDlQPG/w640-h426/computer-monitor-coding-programming-2194062.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[3] Always keep possible code-reuse in mind while coding.&lt;/b&gt; While coding, it is always a good practice to consider the effect of exposing your functionality to other users in the form of a Library/API. Instead of scavenging for bugs later, you will save lots of time and concentration by planning ahead for it.&lt;br /&gt;
&lt;br /&gt;
It is also a good practice to avoid possible formatting of data while returning values from your functions or sub-procedures, and leave those implementation details to the caller instead.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[4] Clean up your unused and local variables.&lt;/b&gt; This is the number one efficient factor that directly affects the performance of your code. Always keep a habit of releasing the memory used by local variables in the Finally block. Also, release all .NET and COM Global/Module-level variables when they are no longer needed.&lt;br /&gt;
&lt;br /&gt;
In order to clear COM objects, you have to call Marshal.ReleaseCOMObject() function explicitly, whereas .NET objects will be released by just setting them to &lt;b&gt;null&lt;/b&gt; (C#) or &lt;b&gt;Nothing&lt;/b&gt; (VB.NET).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[5] Avoid using GoTo statements.&lt;/b&gt; There is nothing inherently wrong with using Goto statements in VB.NET, but they reduce the code-readability. Its easy to lose track of the issue at hand, while scavenging for the possible effects by following your Goto statements.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[6] Always use FxCop to audit your code.&lt;/b&gt; FxCop is a free tool from Microsoft that checks your assembly for compliance with Microsoft Design guidelines.&lt;br /&gt;
&lt;br /&gt;
Apart from highlighting inconsistencies in issues like naming-conventions, an important advantage of using FxCop is that it brings to light several performance improvizations that could be made to your code. Here is the download page for FxCop version 10.0:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?id=6544&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;FxCop download page.&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/3523168614309187820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2012/01/how-to-code-efficiently-in-net-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3523168614309187820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3523168614309187820'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2012/01/how-to-code-efficiently-in-net-language.html' title='How to code efficiently in a .NET language'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwJxZAwRmn64bkjPgA_gXZIiuhlxdnXEGzj-sF1pyZC78EyZt_rvNRCFHgPPyBUtgKCpVUPzu14WYy6AUFEfQfqkU-FN91S54IBeKK1SZAc7MxTg417VNJS3-5Z0DfEHyX3ekyy-SMOUaYe1s9K7pDutTz6Yk7iNGLUNxMNUDgTDDFoB4ka-4q5AgDlQPG/s72-w640-h426-c/computer-monitor-coding-programming-2194062.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-5565013424159715450</id><published>2011-08-06T12:30:00.009+05:30</published><updated>2024-10-12T07:45:14.488+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="c sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="multi-threading"/><category scheme="http://www.blogger.com/atom/ns#" term="vb.net"/><title type='text'>How to perform Cross-thread communication in .NET programs (2011)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;font-family: inherit;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: inherit;&quot;&gt;
Multithreading is a quite useful technique in programming, especially in complex applications that seem to do a lot of things at the same time. The System.Threading class in .NET provides members that allow us to seamlessly create, stop and abort threads at will. But this article is not about managing threads, there are already several texts available for that. This is about managing a very typical scenario that is faced by a developer working on a multi threaded application.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
Quite recently, while developing a network application and using multiple threads, I came across this very problem. The program was basically a TCP Message Server that accepted TCP and UDP requests on the network and replied to them with some processed data. We had one main GUI that acts as the user interface for the server. Now, at the click of a start button, there are two different threads that need to start: a TCPListener and a UDPListener thread. So now, we had three threads:-  &lt;/div&gt;
&lt;ol style=&quot;font-family: inherit;&quot;&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
The  main GUI thread started by the user.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
TCPListener  thread listening for TCP requests on a port.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
UDPListener  thread listening for UDP requests on a different port.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
Here are some parts of the implementation:&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
GUI: Basic Server GUI with a Start/Stop button and a text box for last message received.&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GUI Code:&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;partial&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MsgServer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Form&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpServer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Server;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; MsgServer()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;InitializeComponent();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//call back function called when a message is received at the server&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; MsgServer_MessageReceived(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.txtLastMessage.Text = e.Body;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm; margin-left: 1.27cm; text-indent: 1.27cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//Perform any other processing as per the requirements.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm; margin-left: 1.27cm; text-indent: 1.27cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;//Call Server.SendTcpMessage() function to reply if required.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; MsgServer_Load(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;EventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; MsgServer_FormClosed(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;FormClosedEventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//stop the message server&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Server.StopServer();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; { }&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; btnStart_Click(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;EventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (btnStart.Text == &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Start&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//create a delegate for the call back function&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpServer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedDelegate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; callBack = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpServer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedDelegate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(MsgServer_MessageReceived);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//start the message server at port 2055&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Server.StartServer(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Resolve(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).HostName, 2055, callBack,(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ISynchronizeInvoke&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;btnStart.Text = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Stop&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Server.StopServer();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;btnStart.Text = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Start&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
Server Code:&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpServer&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ServerName; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//name of this server&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; PortNo;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//public MessageReceivedArgs LastMessage = null;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Socket&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; TcpServerSocket;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Thread&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListenTcpThread;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Thread&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListenUdpThread;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;UdpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Udpc;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; IsStarted = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Hashtable&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; TcpClients=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Hashtable&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(); &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//all clients (ip-end points) associated with this server&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//callback when a new message is received&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;delegate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedDelegate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedDelegate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; MessageReceivedCallback;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ISynchronizeInvoke&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Sync;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//public event MessageReceivedDelegate MessageReceived;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//sends a tcp message to a remote host&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; SendTcpMessage(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPEndPoint&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; remoteHost,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; command, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; messageText)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (!IsStarted)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Server is not running&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; hostName = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Resolve(remoteHost.Address.ToString()).HostName;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (hostName == &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Resolve(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).HostName)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;hostName = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; client = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(hostName, remoteHost.Port);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Stream&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; s = client.GetStream();&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;StreamWriter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sw = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;StreamWriter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(s);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;sw.AutoFlush = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;sw.WriteLine(ServerName + &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; + command +  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; + messageText);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;sw.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;s.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;client.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//ping broadcast request to find the specified server&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Ping(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; remoteServer)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (!IsStarted)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Server is not running&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; client = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(); &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//broadcast&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;client.Client.SetSocketOption(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;SocketOptionLevel&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Socket, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;SocketOptionName&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Broadcast, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Stream&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; s = client.GetStream();&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;StreamWriter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sw = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;StreamWriter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(s);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;sw.AutoFlush = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;sw.WriteLine(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ServerName + &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#PING#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; + remoteServer);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;sw.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;s.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;client.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//udp broadcast request to all servers&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Broadcast()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (!IsStarted)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Server is not running&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;UdpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; broadcaster = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;UdpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;230.0.0.1&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, 8899);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;byte&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;[] sdata = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Encoding&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ASCII.GetBytes(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ServerName + &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#BROADCAST#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; + &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.PortNo.ToString());&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;broadcaster.Send(sdata, sdata.Length);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//udp broadcast to all servers that i&#39;m shutting down&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ShutdownBroadcast()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (!IsStarted)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Server is not running&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;UdpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; broadcaster = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;UdpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;230.0.0.1&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, 8899);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;byte&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;[] sdata = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Encoding&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ASCII.GetBytes(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ServerName + &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#SHUTDOWN#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; + &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.PortNo.ToString());&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;broadcaster.Send(sdata, sdata.Length);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StartServer(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; serverName, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; portNo, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedDelegate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; callBack, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ISynchronizeInvoke&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sync)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ServerName = serverName;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.PortNo = portNo;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.MessageReceivedCallback = callBack;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Sync = sync;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//start the tcp thread&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ThreadStart&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ts = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ThreadStart&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(ListenTcpRequests);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ListenTcpThread = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Thread&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(ts);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ListenTcpThread.Start();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//start the udp thread&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ts = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ThreadStart&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(ListenUdpRequests);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ListenUdpThread = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Thread&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(ts);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ListenUdpThread.Start();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IsStarted = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//broadcast to all servers in the network&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//that i&#39;m listening on this port&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;System.Threading.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Thread&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Sleep(250);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Broadcast();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StopServer()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IsStarted = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ListenTcpThread.Abort();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ListenUdpThread.Abort();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//Listener.Stop();&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;TcpServerSocket.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Udpc.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; { }&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListenUdpRequests()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Udpc = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;UdpClient&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(8899);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Udpc.JoinMulticastGroup(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPAddress&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Parse(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;230.0.0.1&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPEndPoint&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ep=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;byte&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;[] rdata = Udpc.Receive(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ref&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ep); &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//blocks until a request is received&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; message = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Encoding&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ASCII.GetString(rdata);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Debug&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.WriteLine(message);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//decode the entire message&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//SENDER_NAME#COMMAND#BODY&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender = message.Split(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToCharArray())[0];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; command = message.Split(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToCharArray())[1];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; body = message.Split(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToCharArray())[2];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//read and process the message command&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;switch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (command)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;case&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;PING&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (body == ServerName)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;SendTcpMessage((ep), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;PING_REPLY&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;case&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;BROADCAST&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ep.Port = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Convert&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToInt32(body);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;SendTcpMessage((ep), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;BROADCAST_REPLY&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;XXXXX&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (!TcpClients.Contains(sender))&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;TcpClients.Add(sender, ep);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;case&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;SHUTDOWN&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (TcpClients.Contains(sender))&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;TcpClients.Remove(sender);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//method to start from a thread that constantly listens to&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//new tcp messages received&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListenTcpRequests()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//configure the tcp listener&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//Listener = new TcpListener(portNo);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//Listener.Start();&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;TcpServerSocket = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Socket&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPAddress&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Loopback.AddressFamily, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;SocketType&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Stream, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ProtocolType&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.IP);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, PortNo);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPEndPoint&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ep = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPEndPoint&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Resolve(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).AddressList[0], PortNo);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;TcpServerSocket.Bind(ep);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;TcpServerSocket.Listen(10);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Socket&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; soc = TcpServerSocket.Accept(); &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//Listener.AcceptSocket(); //blocks until a tcp connection request is received&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Stream&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; s = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;NetworkStream&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(soc);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sr = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(s);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; message = sr.ReadToEnd();&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Debug&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.WriteLine(message);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//decode the entire message&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//SENDER_NAME#COMMAND#BODY&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender = message.Split(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToCharArray())[0];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; command = message.Split(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToCharArray())[1];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; body = message.Split(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.ToCharArray())[2];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;switch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (command)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;case&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;MESSAGE&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//SendTcpMessage((soc.RemoteEndPoint as IPEndPoint ), &quot;RECEIPT&quot;, &quot;&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (TcpClients.Contains(sender))&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;SendTcpMessage((TcpClients[sender] &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;as&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;IPEndPoint&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;RECEIPT&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;case&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;RECEIPT&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//raise the event&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;e.Sender = sender;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;e.Command = command;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;e.Body = body;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//MessageReceived(this, e);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;[] items = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;[2];&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;items[0] = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;items[1] = e;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//MessageReceivedCallback.Invoke(this, e);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Sync.Invoke(MessageReceivedCallback, items);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//LastMessage = e;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;//clean up&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;sr.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;s.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;soc.Close();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ex)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Debug&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.WriteLine(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Error occured: &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; + ex.Message);&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;MessageReceivedArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;EventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Sender;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Command;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Body;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
Until now, everything worked fine. We started facing the issue when we had to send the data received by the TCP listener to the main GUI for processing and display on the form. In our implementation, the TCPListener function passed the received data through a CallBack function to the main GUI. Since the TCP Listener function resided on a different thread than the main GUI, the main GUI thread could not display any of this data on its text-box, form, etc. We faced the following exception when we tried to display the data on these form components:&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Cross-thread operation not valid: Control &#39;txtMessage&#39; accessed from a thread other than the thread it was created on.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
We came to know that the above error occurred on account of the calling thread making using the data returned from the called thread in an inappropriate manner (in this case changing a TextBox value). But this was a practical case where we wanted this cross thread communication done. There were, of course, several other alternatives possible like changing the application to single threaded, using a timer control on the main GUI instead of passing a callback to read the messages, etc. But I was very curious to find a way out for cross-thread communication, since it was quite probable that we will face a similar cross-threading obstacle in some future development too. The solution for this came through an MSDN article about System.ComponentModel.ISynchronizeInvoke. This simple Interface, that allows thread-safe communication between two different threads, so seamlessly solved our problem that I decided to share it with others too.&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
The solution is quite simple. Apart from passing the Callback delegate to the called function, we also need to pass an ISynchronizeInvoke object. So instead of calling the normal Invoke method of the delegate, we will use this object’s Invoke which will synchronize with the main GUI thread ! Here is our new implementation in the server code:&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;//MessageReceivedCallback.Invoke(this, e);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;font-family: inherit; line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Sync.Invoke(MessageReceivedCallback, items);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;font-family: inherit; margin-bottom: 0cm;&quot;&gt;
After the above implementation, our display issue was solved. Hope this will be useful to you. Happy Programming!!&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/5565013424159715450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2011/08/how-to-perform-cross-thread.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/5565013424159715450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/5565013424159715450'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2011/08/how-to-perform-cross-thread.html' title='How to perform Cross-thread communication in .NET programs (2011)'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-7508934410150188570</id><published>2011-07-30T16:40:00.001+05:30</published><updated>2024-10-12T07:44:54.721+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ftp"/><category scheme="http://www.blogger.com/atom/ns#" term="vb.net"/><title type='text'>How to create an FTP client in VB.NET (2011)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The FTP (File Transfer Protocol) is one of the oldest and most popular ways of transferring files from one computer to another over a TCP network such as the internet. It is a Client/Server based protocol based on cear-text authentication. To get a detailed idea of what FTP is and how it is used, refer to &lt;a href=&quot;http://en.wikipedia.org/wiki/File_Transfer_Protocol&quot; target=&quot;_blank&quot;&gt;http://en.wikipedia.org/wiki/File_Transfer_Protocol&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;In .NET,&amp;nbsp; we implement the FTP functionality using the &lt;b&gt;System.Net&lt;/b&gt; namespace. This is a comprehensive namespace which encapsulates functionality to perform various network tasks. These include FTP related tasks like connecting to an FTP server and listing its directory.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;In this article, we will learn how to create an FTP Client using the VB.NET language right from scratch.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The IDE I have used is Visual Studio 2008, though you can easily port it to the 2010 version. The complete source-code for this solution is available on Google Code. You can download it here:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;a href=&quot;http://code.google.com/p/ftpexplorer/downloads/detail?name=ftpexplorer_source_1.zip&quot; target=&quot;_blank&quot;&gt;http://code.google.com/p/ftpexplorer/downloads/detail?name=ftpexplorer_source_1.zip&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;You can also translate it to C# (with a little bit of effort) since all .NET languages share the same FCL and CLI. There is a C# equivalent for each syntax.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;To begin, create a VB solution of the type “Windows Forms Application”. Add a Form to it, then add the below controls to the Form:&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;A  TreeView control – to browse the local file system&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;A  ListView control – to browse the remote ftp structure&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;A  TextBox and a Button to type Url and connect to the FTP server&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;Two  Upload and Download buttons&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;A  multi-line TextBox for logging details&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;A  StatusStrip control with a label on it (Optional)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;This will be your FTP client interface where you can do things like connecting to a remote ftp site using your username and password and start uploading/downloading files. The appearance is quite minimalist, and I have abstained from adding many advanced functions like using an SSL connection and applying cryptography, so as not to overwhelm the learners. Here is our little FTP Explorer in action:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNRBEKFDDs2sOjD6s4m5QblvlHWjWmdScPZqa8F3r7l8oditJEVYPA9Cv-o6d1YWIrYDjiRiYUfciol7FKJEAjwdQfVds84ffMri3EujojDnBReUvv9fgpBgPjKsUu2lMUXMhMCFV3exeT/s1600/ftp_explorer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNRBEKFDDs2sOjD6s4m5QblvlHWjWmdScPZqa8F3r7l8oditJEVYPA9Cv-o6d1YWIrYDjiRiYUfciol7FKJEAjwdQfVds84ffMri3EujojDnBReUvv9fgpBgPjKsUu2lMUXMhMCFV3exeT/s320/ftp_explorer.png&quot; width=&quot;291&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7wlwLbYZXLWSVjxWWu9QWL7ecmyT0bYjYCnmRNTPgUzApaSVVIcKjOyaR00wgxNrQCrMYLEeWz3VT3ofLxus3tOABlyAXwFjbCf70fAHN9pHYFj0WVna5KfDvvobO0_SvmHKWOU1k0ygW/s1600/ftp1.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The Upload button uploads the selected file on the local system to the remote directory that is currently selected. Similarly, selecting a file on the remote system and clicking the download button  downloads the file to the selected local folder.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;On the remote system, double-clicking a folder will navigate to that folder. The big multi-line textbox is for logging the ftp events.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;On the coding front, I have abstracted the core FTP related functionality in a different class called FtpClient, so that the functionality could be reused or exposed through an API.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The local-system&#39;s explorer-tree on the top left side is just filled with the drive letters in the beginning. Later, as the user starts expanding the nodes, they are populated with the sub-folders and files.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; tvwLocal_AfterExpand(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; System.Windows.Forms.TreeViewEventArgs) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Handles&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; tvwLocal.AfterExpand&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;On&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Error&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;GoTo&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; em&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; current &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; TreeNode = e.Node&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;Dim nextFile As String = Dir(current.Name &amp;amp; &quot;\&quot;, FileAttribute.Directory)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; dirInfo &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;() = Directory.GetDirectories(current.Name &amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;\&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        current.Nodes.Clear()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;Do While (nextFile IsNot Nothing AndAlso nextFile.Length &amp;gt; 0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;For&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Each&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; nextFile &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;In&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; dirInfo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; dirnode &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; TreeNode&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            dirnode.Text = ExtractFileName(nextFile)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;span lang=&quot;&quot;&gt;dirnode.Name = nextFile &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39; current.Name &amp;amp; &quot;\&quot; &amp;amp; nextFile&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            dirnode.ImageIndex = Images.CLOSED_FOLDER&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            dirnode.SelectedImageIndex = Images.CLOSED_FOLDER&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;span lang=&quot;&quot;&gt;dirnode.Nodes.Add(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;*DUMMY*&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;current.Nodes.Add(current.Name &amp;amp; &quot;\&quot; &amp;amp; nextFile, nextFile, Images.CLOSED_FOLDER, Images.CLOSED_FOLDER)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            current.Nodes.Add(dirnode)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;Loop&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Next&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;span lang=&quot;&quot;&gt;dirInfo = Directory.GetFiles(current.Name &amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;\&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;nextFile = Dir(current.Name &amp;amp; &quot;\&quot;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;For&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Each&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; nextFile &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;In&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; dirInfo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            current.Nodes.Add(nextFile, ExtractFileName(nextFile), Images.FILE, Images.FILE)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Next&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exit&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;em:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Err.Number &amp;lt;&amp;gt; 52 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;And&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Err.Number &amp;lt;&amp;gt; 57 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            MessageBox.Show(Err.Description)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;As for the FTP handling, the class constructor takes three arguments: the FTP host, username and password. The most important method in this class is the ListDirectory(). This function sends a LIST request to the remote ftp server and gets the directory and files listing in the form of an ftp-string. It then creates an object of FtpDirectory class which is basically a generic list of FtpFileInfo objects. FtpFileInfo is an important object that reads the ftp-string using regular expressions and categorizes them into a file or a folder.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListDirectory(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Optional&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; directory &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; FtpDirectory&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;On&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Error&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;GoTo&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; em&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; url &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; directory.Length = 0 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.CurrentDirectory = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;url = Hostname&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ElseIf&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; directory = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;No need to do anything&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ElseIf&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; directory = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;..&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; CurrentDirectory &amp;lt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;/pub/a&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; index &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Integer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.CurrentDirectory.LastIndexOf(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                CurrentDirectory = CurrentDirectory.Substring(0, index)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; CurrentDirectory.Length = 0 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; CurrentDirectory = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;RaiseEvent&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StatusChanged(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Already in the root directory&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;url = Hostname &amp;amp; &quot;/&quot; &amp;amp; CurrentDirectory&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.CurrentDirectory &amp;amp;= IIf(CurrentDirectory.Length = 1, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;) &amp;amp; directory&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        url = GetCurrentUrl()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;RaiseEvent&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StatusChanged(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Logging in with user &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &amp;amp; Username)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;return a simple list of filenames in directory&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ftp &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Net.FtpWebRequest = GetRequest(url)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;Set request to do simple list&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        ftp.Method = Net.WebRequestMethods.Ftp.ListDirectoryDetails&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; response &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; FtpWebResponse = ftp.GetResponse()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sr &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StreamReader(response.GetResponseStream())&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; str &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; = sr.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;replace CRLF to CR, remove last instance&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        str = str.Replace(vbCrLf, vbCr).TrimEnd(Chr(13))&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;split the string into a list&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Not&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Authenticated &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;span lang=&quot;&quot;&gt;Authenticated = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;True&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;RaiseEvent&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StatusChanged(response.WelcomeMessage)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;RaiseEvent&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StatusChanged(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Login successful...&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;RaiseEvent&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; StatusChanged(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Current directory is &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &amp;amp; CurrentDirectory)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; FtpDirectory(str, url)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Exit&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;em:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        MessageBox.Show(Err.Description)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The regular expressions are matched based on six different unix directory listing patterns that are most commonly used. &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Enum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; DirectoryEntryTypes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        File&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        Directory&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Enum&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; line &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; path &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;parse line&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; m &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Match = GetMatchingRegex(line)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; m &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Is&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Nothing&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;failed&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ApplicationException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;Unable to parse line: &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &amp;amp; line)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.FileName = m.Groups(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).Value&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Path = path&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Size = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;CLng&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;(m.Groups(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;size&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).Value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Permission = m.Groups(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;permission&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).Value&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; _dir &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; = m.Groups(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;dir&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).Value&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; (_dir &amp;lt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;And&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; _dir &amp;lt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.FileType = DirectoryEntryTypes.Directory&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.FileType = DirectoryEntryTypes.File&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.FileDateTime = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Date&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.Parse(m.Groups(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;).Value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ex &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Exception&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;.FileDateTime = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Nothing&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; GetMatchingRegex(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; line &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Match&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
Dim formats As String() = { _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;(?&amp;lt;dir&amp;gt;[\-d])(?&amp;lt;permission&amp;gt;([\-r][\-w][\-xs]){3})\s+\d+\s+\w+\s+\w+\s+(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;timestamp&amp;gt;\w+\s+\d+\s+\d{4})\s+(?&amp;lt;name&amp;gt;.+)&quot;, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;(?&amp;lt;dir&amp;gt;[\-d])(?&amp;lt;permission&amp;gt;([\-r][\-w][\-xs]){3})\s+\d+\s+\d+\s+(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;timestamp&amp;gt;\w+\s+\d+\s+\d{4})\s+(?&amp;lt;name&amp;gt;.+)&quot;, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;(?&amp;lt;dir&amp;gt;[\-d])(?&amp;lt;permission&amp;gt;([\-r][\-w][\-xs]){3})\s+\d+\s+\d+\s+(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;timestamp&amp;gt;\w+\s+\d+\s+\d{1,2}:\d{2})\s+(?&amp;lt;name&amp;gt;.+)&quot;, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;(?&amp;lt;dir&amp;gt;[\-d])(?&amp;lt;permission&amp;gt;([\-r][\-w][\-xs]){3})\s+\d+\s+\w+\s+\w+\s+(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;timestamp&amp;gt;\w+\s+\d+\s+\d{1,2}:\d{2})\s+(?&amp;lt;name&amp;gt;.+)&quot;, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;(?&amp;lt;dir&amp;gt;[\-d])(?&amp;lt;permission&amp;gt;([\-r][\-w][\-xs]){3})(\s+)(?&amp;lt;size&amp;gt;(\d+))(\s+)(?&amp;lt;ctbit&amp;gt;(\w+\s\w+))(\s+)(?&amp;lt;size2&amp;gt;(\d+))\s+(?&amp;lt;timestamp&amp;gt;\w+\s+\d+\s+\d{2}:\d{2})\s+(?&amp;lt;name&amp;gt;.+)&quot;, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;(?&amp;lt;timestamp&amp;gt;\d{2}\-\d{2}\-\d{2}\s+\d{2}:\d{2}[Aa|Pp][mM])\s+(?&amp;lt;dir&amp;gt;\&amp;lt;\w+\&amp;gt;){0,1}(?&amp;lt;size&amp;gt;\d+){0,1}\s+(?&amp;lt;name&amp;gt;.+)&quot;}&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; rx &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Regex, m &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Match&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;For&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; i &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Integer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; = 0 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;To&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; formats.Length - 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;rx = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; Regex(formats(i))&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;m = rx.Match(line)&lt;span lang=&quot;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; m.Success &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; m&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Next&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;dir&gt;&lt;dir&gt;&lt;dir&gt;&lt;dir&gt;&lt;dir&gt;&lt;dir&gt;&lt;/dir&gt;&lt;/dir&gt;&lt;/dir&gt;&lt;/dir&gt;&lt;/dir&gt;&lt;/dir&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;For connecting to the remote ftp server, we use the FtpWebRequest class provided by the .NET framework class library through the System.Net namespace. The StatusChange() event of the FtpClient is used to get notifications in the main form where we can display or log this status on a multi-line text-box.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; client_StatusChanged(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; newStatus &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Handles&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; client.StatusChanged&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        txtLog.AppendText(newStatus &amp;amp;amp; Environment.NewLine)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        Application.DoEvents()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The client object&#39;s ListDirectory() function is again called when the list view item is double-clicked or an upload is complete&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListRemoteDirectory(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; directory &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span lang=&quot;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        lvwRemote.Items.Clear()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;Request = CType(FtpWebRequest.Create(txtUrl.Text), FtpWebRequest)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: green; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&#39;Request.Credentials = New NetworkCredential(cred(0), cred(1))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        RemoteDir = client.ListDirectory(directory)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        LastDirectory = directory&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;span lang=&quot;&quot;&gt;lvwRemote.Items.Add(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;..&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;&quot;..&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;For&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Each&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; item &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; FtpFileInfo &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;In&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; RemoteDir&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; item.FileType = FtpFileInfo.DirectoryEntryTypes.Directory &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                lvwRemote.Items.Add(item.FileName, Images.CLOSED_FOLDER)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                lvwRemote.Items.Add(item.FileName, Images.FILE)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Next&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; lvwRemote_DoubleClick(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; sender &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; e &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; System.EventArgs) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Handles&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; lvwRemote.DoubleClick&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; lvwRemote.SelectedItems.Count = 0 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; item &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; ListViewItem = lvwRemote.SelectedItems(0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; item.ImageIndex = Images.FILE &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; lang=&quot;&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;                ListRemoteDirectory(item.Text)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;&lt;span lang=&quot;&quot;&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The remaining tricks of the trade can be easily understood once you go through the code. For any doubts or queries please contact me.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;.............................................................................................. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;EDIT: As of today (22-07-2012), I&#39;ve re-created this project with the following improvements: &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;1. I&#39;ve realized that the complexity involved in implementing the FTPWebRequest, deserves a modular approach. Hence, I&#39;ve developed the FTP library as a class component (DLL) separate from the GUI component. This way, the library can be reused without the burden or overhead of a WinForm.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;2. Multi-threading: .NET can certainly leverage the multi-threading capabilities of the newer dual-core processors. I&#39;ve hence implemented multi-threading by running uploads/downloads on separate threadeds.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;3. Event-based: I&#39;ve included some more events such as uploadCompleted and downloadCompleted to facilitate the end-users of the library.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;4. Finally, I&#39;ve developed the newer version in the C# language, as I&#39;m more used to it in recent years.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;You can find the newer version in the codeplex repository &lt;a href=&quot;http://libftp.codeplex.com/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: small;&quot;&gt;The update tutorial for C# is &lt;a href=&quot;http://prahladyeri.wordpress.com/2012/07/28/how-to-create-an-ftp-client-in-c/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. &lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/7508934410150188570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2008/12/how-to-create-ftp-client-in-vbnet.html#comment-form' title='41 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/7508934410150188570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/7508934410150188570'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2008/12/how-to-create-ftp-client-in-vbnet.html' title='How to create an FTP client in VB.NET (2011)'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNRBEKFDDs2sOjD6s4m5QblvlHWjWmdScPZqa8F3r7l8oditJEVYPA9Cv-o6d1YWIrYDjiRiYUfciol7FKJEAjwdQfVds84ffMri3EujojDnBReUvv9fgpBgPjKsUu2lMUXMhMCFV3exeT/s72-c/ftp_explorer.png" height="72" width="72"/><thr:total>41</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-4664368505314277720</id><published>2011-07-17T18:06:00.002+05:30</published><updated>2024-10-12T07:44:34.300+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="c sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="network programming"/><title type='text'>Network programming in VB.NET and C# (2011)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The .NET framework provides an extensive set of functions to enable network programming using the objects in System.Net and System.Net.Socket namespaces. Let us look into some basic network concepts that we need to develop, say a chat program or a remote-signaling application in .NET.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
[1] Sockets and Ports:&lt;br /&gt;
&lt;br /&gt;
Socket is the communication agent on the physical network layer. When your computer talks to another one, socket is like a virtual device on your system that sends and receives the TCP packets. Port is like a channel on which packets relating to a specific program are being sent or received. When your program is listening for data on port number 2051, no other program can. In .NET framework, a socket is represented by the object System.Net.Sockets.Socket. However, the object TcpListener can also be used as an alternative to the Socket for listening to TCP packets.&lt;br /&gt;
&lt;br /&gt;
[2] Addresses and Endpoints:&lt;br /&gt;
&lt;br /&gt;
In order to talk to a remote computer, we need to know its IP-address. This is represented by System.Net.IPAddress. It contains special members to get some vital information. For eg, the IPAddress.Loopback gives the local loop-back address to communicate with the local host. This is usually 127.0.0.1.&lt;br /&gt;
An end-point is a combination of an ip-address and a port. As mentioned earlier, we need these two information about a remote computer to communicate with its listening socket. This is System.Net.IPEndpoint.&lt;br /&gt;
&lt;br /&gt;
[3] The Dns namespace:&lt;br /&gt;
&lt;br /&gt;
The namespace System.Dns is very important in .net. Without it you would be crippled to do even basic tasks like resolving a computer&#39;s host name to its ip-address. Below are some key static functions of this object:&lt;br /&gt;
&lt;br /&gt;
Dns.GetHostEntry() - Resolves a given name or address to a specific host (returns IPHostEntry).&lt;br /&gt;
&lt;br /&gt;
Dns.GetHostName() - Returns name of a host computer.&lt;br /&gt;
&lt;br /&gt;
Dns.GetHostAddresses() - Returns all ip-addresses of a given host-name or ip-address.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us now look at some common network tasks to perform in VB.net or C#:&lt;br /&gt;
&lt;br /&gt;
[1] Finding any computer&#39;s ip address: You can easily get the host-name given its ip-address by the GetHostEntry(), but how will you find the ip-address given its name? Here you have to check the array of addresses returned by the GetHostName(), as done in the below c# function that you can add in your class:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;public IPAddress GetAddressFromHost(string hostName)
{
//IPAddress address = Dns.GetHostEntry(txtRemoteHost.Text).AddressList[0];
IPHostEntry host = Dns.GetHostEntry(hostName);
IPAddress[] addresses = Dns.GetHostAddresses(host.HostName);
IPAddress address;
if (addresses[0].ToString() == &quot;127.0.0.1&quot; &amp;amp;&amp;amp; addresses.Length &amp;gt; 1)
{
address = addresses[1];
}
else
{
address = addresses[0];
}
return address;
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
[2] Sending a tcp message to another computer. All you need to know is the remote computer&#39;s host-name or ip-address and the port number on which it is listening to. You will have to make use of the Stream object to write your message:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;public void SendMessage(string remoteHost, int remotePort, string command, string body)
{
try
{
//string hostName = Dns.GetHostEntry(remoteClient.EndPoint.Address).HostName;
string localHostName = Dns.GetHostEntry(&quot;localhost&quot;).HostName;
TcpClient client = new TcpClient(remoteHost,remotePort);
//TcpClient client = new TcpClient();
Stream s = client.GetStream();
StreamWriter sw = new StreamWriter(s);
sw.AutoFlush = true;
sw.Write(localHostName + &quot;#&quot; + PortNo.ToString() + &quot;#&quot; + ServerName + &quot;#&quot; + command + &quot;#&quot; + body);
sw.Close();
s.Close();
client.Close();
}
catch
{
}
}
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/4664368505314277720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2011/07/network-programming-in-vbnet-and-c.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/4664368505314277720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/4664368505314277720'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2011/07/network-programming-in-vbnet-and-c.html' title='Network programming in VB.NET and C# (2011)'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2487169160564872308.post-3527901977556833958</id><published>2011-02-27T08:44:00.001+05:30</published><updated>2018-07-18T11:37:42.375+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="c sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="CAPTCHA"/><title type='text'>How to develop CAPTCHA functionality in ASP.NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Ever wondered after seeing those little curvy digits in neat boxes followed by input saying “Enter the above text:”, where do they come from?&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&amp;nbsp;This usually happens when you register for a free online service like an email-id or FTP service. Such validation may also happen before you submit any comment on a blog or website. You might wonder, after all what is the point of this? &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWAZGsCUsFfRfh_OqvjAwxLm6j61tK0ur1plr9QmBg02BlT5K0PA8DvWtpl-iRLVLEdq_XMX0AenvUO6wOWm30wWS4WIXgLfHOfTWPysVQYuk86ISasphzga5CnPjnACFeR1bAER0OGPPT/s1600/captcha1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWAZGsCUsFfRfh_OqvjAwxLm6j61tK0ur1plr9QmBg02BlT5K0PA8DvWtpl-iRLVLEdq_XMX0AenvUO6wOWm30wWS4WIXgLfHOfTWPysVQYuk86ISasphzga5CnPjnACFeR1bAER0OGPPT/s1600/captcha1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFOm-Rwn6WectG8XpzOW-EPhpwCNHwWc77esGWOR_U_zAA9sjG6v1irL_A0BgGDLaJF9M7TDTFYLfjN_O1k5ZCudZ1wpeliKdb6c8MS1sTQ8ml4j435-OYZGwGkejyKyVni9S6YuvynTcR/s1600/captcha2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-RyMT577KEXQ/TWnC5DAma6I/AAAAAAAAAUw/YQWSvnOjflE/s1600/captcha1.png&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-I_qEECwTOy0/TWnDOM2lkTI/AAAAAAAAAU4/E7Jw8LFLxM4/s1600/captcha2.png&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea is to incorporate a validation to protect from spam and stop internet bots from automatically submitting forms on your website. CAPTCHA stands for “Completely Automated Public Turing Test To Tell Computers and Humans Apart”.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqKotcLViZgxgn4Eeh7mvPyovrgk6M3dP3oPi6HmR4zD2_YIh_6_AfaY7NGE4cZmDJ58qGjI4THZNEBqVPgeY373mNI4iUWthe8oGBDYTrnZAQLn4_VTrTu0aDUyBmMxGMan0AyJnbgtOD/s1600/captcha3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
Computers have automated most of the tasks that humans do on the net, and creating a program to impersonate a human by filling some text-boxes on a HTML form is a very simple task in a language like Java, VB.net or C#. Such programs are called auto-bots or internet-bots that are usually used by spammers. &lt;br /&gt;
Bots are also used to manipulate results of online-polls. For instance, in November 1999, Slashdot released an online poll asking which was the best graduate school to study computer science. IP addresses of voters were recorded in order to prevent single users from voting more than once. However, students at Carnegie Mellon found a way to stuff the ballots using programs that voted for CMU thousands of times. CMU&#39;s score started growing rapidly. The next day, students at MIT wrote their own program and the poll became a contest between voting bots. MIT finished with 21,156 votes, Carnegie Mellon with 21,032 and every other school with less than 1,000!&lt;br /&gt;
&lt;br /&gt;
Can the result of any online poll be trusted? Not unless the poll ensures that only humans can vote. And that can be done by using CAPTCHA. It is not necessary that CAPTCHA should be a manual image verification. It could even be a common sense question like “What is the capital of India?” or “What is one plus one?”.&lt;br /&gt;
Such simple questions for humans are still a challenge for most AI programs, and it is very difficult to write a generic bot to create such a complex task that involves natural language processing. However, if somebody is specifically targeting your website, this question can be easily bypassed as the answer will be “Delhi” each time the form is submitted.&lt;br /&gt;
Moreover, for a small website, it is difficult to come up with a dictionary of so many questions and switch between them randomly. Ultimately each one will be deciphered after several attempts by the bot.&lt;br /&gt;
The only full-proof solution is image based verification. Reading curved letters is one of the few tasks done on a computer, in which even the present best technology cannot beat the cortex. Consider the below image:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFOm-Rwn6WectG8XpzOW-EPhpwCNHwWc77esGWOR_U_zAA9sjG6v1irL_A0BgGDLaJF9M7TDTFYLfjN_O1k5ZCudZ1wpeliKdb6c8MS1sTQ8ml4j435-OYZGwGkejyKyVni9S6YuvynTcR/s1600/captcha2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFOm-Rwn6WectG8XpzOW-EPhpwCNHwWc77esGWOR_U_zAA9sjG6v1irL_A0BgGDLaJF9M7TDTFYLfjN_O1k5ZCudZ1wpeliKdb6c8MS1sTQ8ml4j435-OYZGwGkejyKyVni9S6YuvynTcR/s1600/captcha2.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-I_qEECwTOy0/TWnDOM2lkTI/AAAAAAAAAU4/E7Jw8LFLxM4/s1600/captcha2.png&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Reading the above image involves three tasks (from a computer’s point of view):&lt;br /&gt;
1. Pre-processing: Removing the background clutter and noise.&lt;br /&gt;
2. Segmentation: Splitting the image into regions which contain a single character.&lt;br /&gt;
3. Classification: Identifying the character in each region.&lt;br /&gt;
In fact, tasks 1 and 3 are pretty easy for a computer. This is being done since ages through a technology called OCR (Optical Character Recognition). Only the task 2, of differentiating each character still remains a challenge for even the most advanced AI programs. On the other hand, it is a piece of cake, for even the most dumbest of humans.&lt;br /&gt;
&lt;br /&gt;
Now, let us get down to the technical task of creating such a random image, and verifying the same in ASP.net. Assuming that you know the basics of ASP.net like developing web-forms, code-behind pages, handling session variables, etc. I’ll start with the particulars of creating this functionality. The language I’m using is c-sharp, but VB.net alternatives also exist for those who are interested. The .net framework being used in the example is 2.0 and development tool is Visual Studio 2005.&lt;br /&gt;
Basically, we need one web-form (.aspx) and one class (.cs) file to develop this functionality. Although, you can merge both into one, I suggest you keep the bitmap-creation part in the class, while rendering the output to the browser using .aspx. Apart from these two, there will be a third web-form that uses the CAPTCHA functionality. This will typically be a login page or a comment page on the blog.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CaptchaImage.cs: &lt;br /&gt;&lt;br /&gt;    &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;&lt;b&gt;public int height = 0;
    public int width = 0;
    public string familyname = &quot;Verdana&quot;;
    public string text=&quot;&quot;;
    public Bitmap image;

    private Random random = new Random();

    public void dispose()
    {
        image = null;
        random = null;
 }
    public void GenerateImage()
    {
        Bitmap bt = new Bitmap(this.width,this.height,System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        
        //Create the graphics object
        Graphics g = Graphics.FromImage(bt);
        g.SmoothingMode = SmoothingMode.AntiAlias;
        Rectangle rect = new Rectangle(0, 0, this.width, this.height);

        //Fill the background
        HatchBrush hb = new HatchBrush(
            HatchStyle.SmallConfetti,
            Color.LightGray,
            Color.White);
        g.FillRectangle(hb, rect);

        //Text font
        SizeF size;
        float fontsize = rect.Height + 1;
        Font font;

        //Adjust the text size until the text fits within the image
        do
        {
            fontsize--;
            font = new Font(
            this.familyname,
            fontsize,
            FontStyle.Bold
                );
            size = g.MeasureString(text,font);
        } while (size.Width &amp;gt; rect.Width);

        //Text format
        StringFormat format = new StringFormat();
        format.Alignment = StringAlignment.Center;
        format.LineAlignment = StringAlignment.Center;

        //Create text path &amp;amp; warp it randomly
        GraphicsPath path = new GraphicsPath();
        path.AddString(text, font.FontFamily, (int)font.Style, font.Size, rect, format);
        float v = 4F;
        PointF[] points = 
        {
        new PointF(this.random.Next(rect.Width)/v,this.random.Next(rect.Height)/v),
        new PointF(rect.Width - this.random.Next(rect.Width)/v,this.random.Next(rect.Height)/v),
        new PointF(this.random.Next(rect.Width)/v,rect.Height- this.random.Next(rect.Height)/v),
        new PointF(this.width- this.random.Next(rect.Width)/v,this.height- this.random.Next(rect.Height)/v)
        };
        Matrix matrix = new Matrix();
        matrix.Translate(0F, 0F);
        path.Warp(points, rect, matrix,WarpMode.Perspective,0F);

        //Draw text
        //hb = new HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray);
        hb = new HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray);
        g.FillPath(hb, path);

        //Random noise
        int m = Math.Max(rect.Width, rect.Height);
        for (int i = 0; i &amp;lt; (int)(rect.Width * rect.Height / 30F); i++)
        {
            int x = this.random.Next(rect.Width);
            int y = this.random.Next(rect.Height);
            int w = this.random.Next(m/50);
            int h = this.random.Next(m/50);
            g.FillEllipse(hb, x, y, w, h);
        }
        
        //Clean up
        font.Dispose();
        hb.Dispose();
        g.Dispose();

        //set image
        this.image = bt;
    }&lt;/b&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
Above code is the heart of your CAPTCHA functionality. Input is provided to this object using public variables like height, width and text. A graphics object is used to create the bitmap. Hatch brush is used to first fill the background, and later draw the text. The curved appearance to the end result is given by the warp() method of the graphics path, and also by the style of the Hatch brush.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Default.aspx.cs:&lt;br /&gt;&lt;br /&gt;    &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;&lt;b&gt;protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session[&quot;CaptchaText&quot;] = GenerateRandomCode();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == Session[&quot;CaptchaText&quot;].ToString())
        {
            Label1.Text = &quot;Validation successful&quot;;
        }
        else 
        {
            Label1.Text = &quot;Incorrect Captcha&quot;;
            Session[&quot;CaptchaText&quot;] = GenerateRandomCode();
        }
    }
    public static string GenerateRandomCode()
    {
        char c = (char)0; int dice = 0;
        string res = &quot;&quot;;
        for (int i = 0; i &amp;lt;= 3; i++)
        {
            dice = random.Next(2,2);
            switch (dice)
            {
                case 1: //A
                    c = (char)random.Next(65, 90);
                    break;
                case 2: //a
                    c = (char)random.Next(97, 122);
                    break;
                case 3: //1
                    c = (char)random.Next(48, 57);
                    break;
            }

            res += c.ToString();
        }

        return res;
    }&lt;/b&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
This will be your login or comment web-form that uses the CAPTCHA functionality. In the code-behind file, you need to generate a random Captcha and store in a session variable in the page-load. Here, it is important to check that generation is done only if it is not a PostBack, else it is a case of validating existing Captcha posted by the user. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Default.aspx:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&lt;b&gt;
&amp;lt;asp:Image ID=&quot;Image1&quot; runat=&quot;server&quot; ImageUrl=&quot;~/Views/Home/CaptchaJPEG.aspx&quot; /&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;br /&amp;gt;
    &amp;lt;asp:TextBox ID=&quot;TextBox1&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;asp:Button ID=&quot;Button1&quot; runat=&quot;server&quot; OnClick=&quot;Button1_Click&quot; Text=&quot;Submit&quot; /&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;br /&amp;gt;
    &amp;lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;/b&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
In Default.aspx i.e. the Front-end part, we just take normal image control. Instead of assigning its ImageUrl property to a .jpg/.gif, we assign it to an .aspx page, CaptchaJPEG.aspx. This web-form will do rendering the bitmap part. It will call the CaptchaImage class’s GenerateImage() function to generate the bitmap using the text from the session variable.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CaptchaJPEG.aspx.cs:&lt;br /&gt;&lt;br /&gt;    &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;&lt;b&gt;CaptchaImage captcha = new CaptchaImage();
    protected void Page_Load(object sender, EventArgs e)
    {
        captcha.width = 250;//200;
        captcha.height = 50;//50;
        captcha.text = this.Session[&quot;CaptchaText&quot;].ToString();
        captcha.GenerateImage();

        captcha.image.Save(this.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
    }&lt;/b&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
Once you hook up the above things correctly, all you have to do is start your Default.aspx in a web browser. If everything goes right, you will see a nice piece of CAPTCHA validation functionality as seen below:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqKotcLViZgxgn4Eeh7mvPyovrgk6M3dP3oPi6HmR4zD2_YIh_6_AfaY7NGE4cZmDJ58qGjI4THZNEBqVPgeY373mNI4iUWthe8oGBDYTrnZAQLn4_VTrTu0aDUyBmMxGMan0AyJnbgtOD/s1600/captcha3.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqKotcLViZgxgn4Eeh7mvPyovrgk6M3dP3oPi6HmR4zD2_YIh_6_AfaY7NGE4cZmDJ58qGjI4THZNEBqVPgeY373mNI4iUWthe8oGBDYTrnZAQLn4_VTrTu0aDUyBmMxGMan0AyJnbgtOD/s320/captcha3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://dot-net-talk.blogspot.com/feeds/3527901977556833958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dot-net-talk.blogspot.com/2011/02/how-to-develop-captcha-functionality-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3527901977556833958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2487169160564872308/posts/default/3527901977556833958'/><link rel='alternate' type='text/html' href='http://dot-net-talk.blogspot.com/2011/02/how-to-develop-captcha-functionality-in.html' title='How to develop CAPTCHA functionality in ASP.NET'/><author><name>Prahlad Yeri</name><uri>http://www.blogger.com/profile/12769325975373447545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-p_OoIJ-za4Jin2Tjvns0Vn4B9fTyJ-AD1oq92Xsd2UuVap77jYYsTUlI_IwURc4fVU-Z-38EKJ4KFpG6HK3rBgHNg7F8HVTBysHFmzpbN6tRwO69TD5N7e04ACBaVA/s111/prahlad_yeri.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWAZGsCUsFfRfh_OqvjAwxLm6j61tK0ur1plr9QmBg02BlT5K0PA8DvWtpl-iRLVLEdq_XMX0AenvUO6wOWm30wWS4WIXgLfHOfTWPysVQYuk86ISasphzga5CnPjnACFeR1bAER0OGPPT/s72-c/captcha1.png" height="72" width="72"/><thr:total>1</thr:total></entry></feed>