Execute tasks in parallel using async and await to speed up computation

Suppose you have five tasks you want your computer to execute and that each takes 1 second to execute. In the old days, one would figure that each task would be executed sequentially, resulting in a total execution time of 5 seconds. Even today, many programmers would write a program to execute these tasks sequentially….

0

Cartoon animation works great on Surface Pro

I showed my 9 year old son a cool drawing program called Physamajig, in which users can draw objects, which behave like real physical objects, including reacting to gravity, friction, and bounce. He was having fun with it on my Surface RT and it reminded me of another program. Years ago (around 1981) when I…

1

Create multiple threads to see if work is done simultaneously

When you hear about threads and threading, you hear that they allow concurrent execution of code, which is supposed to lead to better performance. Most computers nowadays have more than one CPU, meaning that each CPU can be executing code at the same time. Hit Ctrl-Shift-Escape to bring up Task Manager, then switch to the…

0

Returning data from a recursive method

  Sometimes you need to write a method that requires recursion to be elegant. Often that method needs to accumulate data between recursion levels There are many ways to do so, and some are more elegant than others. I like the Optional Parameter method: it requires no additional class or static (shared in VB) members…

1

Comment/Uncomment code to switch versions quickly without using macros

In a typical day, I write or debug programs in several languages: typically Foxpro, C#, VB, C++ and 32 bit assembly, with an occasional MSIL, IDL and 64 bit ASM thrown in.   Sometimes, I like to switch between one version of code and another. This is useful if I want to do side by…

7

Make your code more maintainable: The evils of the Return statement

What does it mean to make code more maintainable? Certainly obfuscated code is hard to understand, by definition.   A big part of maintainability is making it easier for others to read and understand what the code is doing. Your code may have been working for years, but then somebody comes along and wants to…

9

Use a dictionary to help create a mnemonic

I was using a program that was yet another TLA and I wanted to create a mnemonic to help me remember what it was. One of the letters was “k”, so I wanted to find a word that starts with “k”   Simple: load a dictionary, search for words starting with “k” and browse through…

2

How to interrupt your code

I received a question:     Simply, is there a way of interrupting a vfp sql query once it has started short of closing down the process ? I am running some complex queries on very large datasets which can sometimes take many minutes to complete.     Typically, a program that runs on your…

6

Examine .Net Memory Leaks

Writing programs using .Net is very productive. One reason is because much of memory management is “managed” for you. In C, C++ and other “native” languages, if you allocate memory, you’re responsible for freeing it.  There were stopgap measures, like destructors, SmartPointers and reference counting, which helped, but were still cumbersome.   Foxpro manages memory…

8

Is this a Vista bug?

A customer reported a crash of a VFP application while running under the new version of Windows: Vista. The customer code attempted to automate the configuration of the web server (See Automating Web Site Administration Using IIS).   Specifically, there was a scenario under which the user code calling GETOBJECT(“IIS://LOCALHOST/W3SVC/1/ROOT”) would crash. At the time,…

4