This version of the page http://lvivcommunity.net/?tag=/threading (0.0.0.0) stored by archive.org.ua. It represents a snapshot of the page as of 2008-06-05. The original page over time could change.
Lviv .NET Community - All posts tagged 'threading'
(Lviv community of .NET developers)
Home News
  • Archive
  • About
  • Conferences
  • |  
  • Sign in / Register

Recent posts

TCP ports forwarding, tunneling, proxies

апреля 27, 2008 09:32 by alexk
Hi Everyone,

Today I want to share a small piece of code that demonstrate TCP Sockets usage in .NET.

This is not very advanced example of sockets programming, but at the same time it show a lot of technics that you can use in programming, like:
- debugging of the windows services
- async sockets
- async operations and there synchronization
- events used for service controlling
- registry access
- advanced tracing/logs
- and etc.

Introduction

The idea was to write a simple TCP proxy class that will help us to forward ports (or better to say create a tunnel) from one source to destination.

In my case I want to use this functinality to open direct access to my computer in network shown below (ADSL modem connected by lan to the Vista computer; Vista publich AdHoc connection to the other computer Windows Xp. I setup service on Vista PC that helps me to open port directly for the Windows XP computer!!!):


In more simple way it's looks like this (configuration for testing):

... >>>

Currently rated 5,0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: tcp, sockets, windows service, traceswitch, threading, trace, tunnel, forwarding, proxy, command line
Categories: Performance | .NET | General | Administration | Networking
Actions: Permalink | Comments (0) | RSS

Windows&Threads

августа 13, 2007 22:00 by rat

Hi,

 

Recently I have been reading about the threading support in WPF, and it is mostly the same as in WinForms. 

But some things are different, for example here is how we make second window running in it's own thread: 

 

 private void NewWindowHandler( object sender, RoutedEventArgs e )

{

 Thread newWindowThread = new Thread( new ThreadStart( ThreadStartingPoint ) );

 newWindowThread.SetApartmentState( ApartmentState.STA );

 newWindowThread.IsBackground = true;

 newWindowThread.Start();

}

 

private void ThreadStartingPoint()

{

 Window1 tempWindow = new Window1();

 tempWindow.Show();

 System.Windows.Threading.Dispatcher.Run();

}

 

So the trick is that we create the window in a separate thread, window's Dispatcher is attached to the thread it is created on, so the window is not attached to the main GUI thread.

Than we just  start the processing of message queue by calling Dispatcher.Run()

The original source of this piece of wisdom is here: 

http://msdn2.microsoft.com/en-us/library/ms741870.aspx 

 


Currently rated 5,0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: wpf, threading
Categories: WinFx
Actions: Permalink | Comments (0) | RSS