Author Archives: tabcom

Simple Backup script (mid to long term)

Call the script “backup_manual.cmd” and run it once a week, once a term or once a year if you like.  It will save data in a ‘year’ folder i.e. “2015” which will be overwritten each time the script is run.  The next year, it will start overwriting next year’s folder.

Note: You will need sufficient free space on your USB hard disk as each year a new backup set is created.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: If site uses multiple HDDs for backup rotation:           ::
::   - only connect one HDD at a time to retain drive letters::
::   - make sure they all are assigned the same drive letter ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off
SETLOCAL

::::::::::::::::::::
:: Site Variables ::
::::::::::::::::::::

set usb=F:
set year=%date:~10,4%
set dest=%usb%\Backup\%year%
set switches=/E /NP /NFL /tee /R:1 /W:1 /MIR /COPYALL
set robocopy=%windir%\system32\robocopy.exe

::::::::::::::::::::
:: Initialization ::
::::::::::::::::::::

if not exist "%usb%"  exit
if not exist "%dest%" md "%dest%"

:::::::::::::
:: Backup  ::
:::::::::::::

"%robocopy%" "c:\folder1" "%dest%\folder1" %switches% /LOG:"%dest%\backup_folder1.log"
"%robocopy%" "c:\folder2" "%dest%\folder2" %switches% /LOG:"%dest%\backup_folder2.log"
"%robocopy%" "c:\folder3" "%dest%\folder3" %switches% /LOG:"%dest%\backup_folder3.log"

:End
ENDLOCAL
:Exit
Simple Backup script (mid to long term) was last modified: March 18th, 2015 by tabcom

Newsletters (or the use of HTML in emails)

There are a few rules to keep in mind when creating an HTML email:

    • HTML fixed width tables should be used for layout.  Using div tags may work, but is not recommended as this is more suited for dynamic rather than fixed page layouts.
    • You can use CSS for inline elements such as background colors and fonts styling.
    • You can use CSS img tags for images.  Use absolute links like “http://…” and not relative links like “/images/…”
    • Give your images alt attributes; it’s absolutely vital in HTML emails.  By default, many email clients do not display images when an email is first opened. Instead, they ask users to actively choose to display images.
    • Remember to wrap each block of text in span tags.  This allows you to specify formatting styles.  Set the font-family to arial, sans-serif; and the color to black.

Example

<table style="border-left: 2px solid #e6e6e6; border-right: 2px solid #e6e6e6;" cellspacing="0" cellpadding="25" width="605">
<td width="596" align="center" style="background-color: #ffffff; border-top: 0px solid #000000; text-align: left; height: 50px;">
<p style="margin-bottom: 10px; font-size: 22px; font-weight: bold; color: #494a48; font-family: arial; line-height: 110%;">
Newsletter - Your monthly source of information</p></td>
<tr>
<td style="background-color: #ffffff; border-top: 0px solid #333333; border-bottom: 10px solid #FFFFFF;" align="middle" valign="middle">
<a href="#"><img src="http://mywebsite.com/images/banner.jpg" border="0" alt="Banner Image" align="center" /></a></td>
<tr>
<td style="background-color: #ffffff; border-top: 0px solid #000000; text-align: left; height: 50px;" align="center">
<p><span style="margin-bottom: 10px; font-size: 12px; font-weight: normal; color: #494a48; font-family: arial; line-height: 110%;">Paragraph text here!</span></p>
<p><a href="link" style="font-family: arial"><span style="font-family: arial; font-size: 12px; color:#b0589d">Link -&gt;</span></a></p>
<p><a href="#"><img src="http://mywebsite.com/images/spacer.jpg" border="0" alt="Frog on a log" align="center" /></a></p> </tr> </table>

The result would look something like this:
(Note: images are not shown as the website address used -‘http://mywebsite.com’- is not real)

newsletter

Newsletters (or the use of HTML in emails) was last modified: March 18th, 2015 by tabcom

Debugging a multi-threaded application in VB .NET

Problem

The following subroutine is part of a client/server chat application written in VB .NET.  The code below is part of the chat client.  It runs in a separate thread from the main thread and listens indefinitely for incoming data from the chat server application.  The problem is that when the application is closed, the process keeps running in the background.  Please assist.

The chat client application contains a form with a button to connect to the chat server application via a TCP/IP socket connection:

thread01

The code “Dim ctThread As….” spawns a new thread that listens continuously (and indefinitely) for new incoming messages sent to listening clients by the chat server application.

Here you see the actual subroutine that is being run in a separate thread:

thread02

When you run the code in Visual Studio Express, you can step through the code, set breakpoints and see the familiar yellow marked line of text indicating the main thread code execution pointer.

When the chat client application is closed by closing the form,  the process keeps running however.  If I press CTRL-Break, I am presented with a green marked line of text indicating the sub-thread code execution pointer.

No matter what, it always seems to be executing instruction “serverStream=clientSocket.GetStream()”

I have to go into Task Manager and kill the chat client process to recover from this situation.

Can you assist please?

Continue Reading →

Debugging a multi-threaded application in VB .NET was last modified: March 24th, 2015 by tabcom