Michael A. Covington    Michael A. Covington
Books by Michael Covington

Previous months
About this notebook
Search site or Web
Ichthys

Daily Notebook

Popular topics on this page:
The Panic of 2008 is over...
Cancelling a C# BackgroundWorker
Will Mars look as big as the full moon on August 27?
Melody returns to free-lance graphic design

For more topics, scroll down, press Ctrl-F to search the page, or check previous months.

-
-
2009
June
29-30

Melody returns to free-lance graphic design

After two and a half successful years working in industry, Melody is returning to free-lance graphic design. Her web site will be updated in a few days. In the meantime, you can contact her through me.

Main specialties are logo design (examples above), design for print media (including brochures and publications of all types), graphics for the Web (including site development in HTML), product photography, and photo restoration. A previously major specialty, book typesetting with LaTeX, is being scaled down since most publishers now have their own arrangements.

2009
June
28

Read this instead...

My old friend Brantley Coile, inventor extraordinaire, has started a blog. The first entry talks about the origin of network address translation. Good reading...

2009
June
27

(Extra)

Short notes

Jeff Duntemann's ContraPositive Diary site is down, probably because of hackers, but the mirror of it on LiveJournal is still up and will carry updates.

To my surprise and delight, the American Medical Association, of all people, has joined the fight against wasteful outdoor lighting. The reason? Glare is bad for older drivers at night; their eyes are more affected by glare than younger eyes. Shine the lights on the street, not into our faces, please, is my request.

2009
June
27

The life cycle of small business

I've just read The E-Myth Revisited, by Michael Gerber. This is an interesting book, but it rambles for 270 pages. If Peter F. Drucker had written the same book, it would have been a 10-page essay, with an apology for the length. I'm going to try to cover it in one Notebook entry.

The "E-Myth" is the notion that, to succeed in small business, all you need is knowledge of how to do the work, and this automatically qualifies you to be an entrepreneur.

Actually, you have to be three things: technician (skilled worker), entrepreneur (strategist), and manager (preserver of efficiency and the status quo). These three personalities need to coexist in the owner's head. In fact, they usually do, and they get into conflict.

The three personalities correspond to the life cycle of a small business: infancy (dominated by the technician, working practically as a free-lancer), adolescence (dominated by the entrepreneur's struggle to expand, often rather like having a tiger by the tail), and maturity (dominated by the need for good management). Failure is likely at each of the transition points.

The key to successful expansion is division of function (so that you don't have 5 people trying to help each other do the same job) and also getting knowledge written down rather than relying on everyone to learn by doing.

Good observations. The book, however, rambles. It may tell us something about the state of management, as a field, that so many popular books about it are very loosely organized.



No longer overfed

Restaurant portions are getting smaller (at both Chili's and On The Border), and I'm glad. For too long, restaurant meals were simply too big to eat. With the smaller portions, the prices are also coming down, at least at Chili's.



Farewells

In the space of two days, Hollywood has said farewell to Ed McMahon, Farrah Fawcett, and Michael Jackson, and my extended family has said farewell to Brazzle Augusta Young, Sr., my mother's sister's husband. (For decades, many of us thought his first name was Braswell.) He was an accomplished man, a machinist who was a civilian employee of the Marine Corps. And he lived to see his first great-great-grandchild.

2009
June
26

Detail

For those who want a closer look, here's the central part of yesterday's picture, at full resolution. You can see that some "mushrooming" occurred on the worn-out ratchet, but I don't think it actually accounts for all the missing metal. Much of it must have just worn off. I'm surprised that the teeth didn't become more rounded as this happened.



Should only rich people become doctors?

A talk-radio host who promotes "debt-free living" was telling a young lady today that taking out a student loan to go to pharmacy school is "stupid." This implies that people of modest means simply shouldn't become pharmacists or doctors. They should stay down there in the working class where they belong... is that the idea? Although I'm in favor of thrift, there is a dark side to the "debt-free" movement, and this is part of it.

Which brings me to a point made recently by economist Greg Mankiw. In some countries, the government pays for people to go to medical school. In America, medical students take out loans and have to earn the money back by practicing medicine. Result? The cost is probably about the same either way, but other countries call it "education spending" and we call it "health-care spending."

2009
June
25

Effect of wear on a ratchet

In the foreground you see the worn-out ratchet (they call it a pawl rack) from a 10-year-old La-Z-Boy model 00515 recliner. In the background is a new one.

The symptom was that the chair would no longer latch in a reclined position. (The teeth of the rack, of course, define positions in which it is supposed to latch.) La-Z-Boy gives a lifetime warranty on parts, and they gladly sent me a replacement, along with a new pawl (the knife-edge-like part that engages the rack).

Notice that years of wear did not round off the teeth, as I expected — instead it reshaped them so that, while still reasonably sharp, they are no longer the right shape to hold the pawl. Admittedly, I had already tried to resharpen the teeth on the old one, but they were only slightly rounded when I started. It was the angle of the sides of the teeth, not the sharpness of the tips, that made the difference.

I don't entirely understand this. But now the chair works like new.

2009
June
24

Short notes

As you follow events in Iran, note that Khamenei and Khomeini aren't the same person — which is not obvious when you look at their pictures! One is the other's successor. You sort them out.

Here is a nice post-mortem on "Clear," the now-defunct company that charged you $200 a year for the privilege of going to the head of the security line in the Atlanta Airport.

And, as I predicted, the new hot issue in the credit-card industry is regulation of interchange fees. Yes, we know they won't make as much money. That's no tragedy.

2009
June
23

The things I have to endure...

We needed a new yellow toner cartridge for our Hewlett-Packard color laser printer. To remind me of this last night, Melody sang, to the tune of a song we heard too many times in the 1970s,

"Buy a yellow cartridge for the old HP..."

2009
June
22

(Continued)

Mystery songs

You can find anything through Google, and I found a few songs I hadn't heard since elementary school music class. One is Ifca's Castle, although I think we sang only the first verse, which sets up the scene but doesn't give the explanation. Full (?) lyrics here. This is apparently a Czech song, although I haven't seen any lyrics in Czech.

Another is Sarasponda, which we were told was a Dutch folk song about a spinning wheel. But as far as I can tell, the language isn't Dutch. I don't know if it's more than nonsense syllables. But it stuck in my mind in fifth grade.

2009
June
22

Burglars welcome?

Everybody's paranoid about "identity theft," but everybody's forgotten about good old-fashioned burglary, which (around here) is more common than it used to be.

I'm dismayed at how many people announce on Facebook and in blogs that they're going to be away from home. I never do that. When I take a trip, you hear about it afterward. You also don't hear whether the house was really empty — we have two grown children and it's uncommon for all four of us to be gone. Then there are the animals, and the electronic security devices...

Even on Facebook, you're never sure just your friends are reading it. Do you belong to a local network such as "Atlanta"? If so, all of Atlanta can read much of your material, including people who just say they're in Atlanta and might actually be anywhere.

2009
June
21

More antivirus notes

Correspondents tell me that NOD32 is highly recommended (but not free) and avast! has a good free version.

These are for people who don't need extremely heavy-handed virus protection. Now if you're in the habit of downloading things without knowing what they are, you may need more...

2009
June
20

Antivirus cautions

Cathy cautions us that AVG Free Antivirus version 8 appears to have a memory leak, or something, and has seriously slowed down her computer (and many others she's heard of). Presumably they'll fix this, but right now, be cautious.

Meanwhile, at work, we've had some problems with another antivirus package, and the upshot is that defective antivirus software can slow down a disk without hogging the CPU, so it looks just as if a disk drive were failing.

Apart from AVG, is there another free "lightweight" antivirus program? By "lightweight" I mean "suitable for people who aren't likely to get a virus and don't want to devote a lot of CPU time to virus hunting."

2009
June
19

Meet the Cleveland Median CPI

Some of what I've been saying about inflation is related to a point now being made by Harvard economist Greg Mankiw with the aid of the Federal Reserve Bank of Cleveland.

The people in Cleveland have devised the median CPI, which looks at all the commodities that comprise the Consumer Price Index — each of which goes up or down by a different amount — and uses whichever one happens, at any particular moment, to be in the middle of the range. Being a nonparametric statistic, the median is immune to outliers. That is, if one commodity does something weird (as gasoline has done recently), the median CPI is totally unaffected. It only measures movements of the entire bunch.

2009
June
18

Francis Schaeffer in a nutshell

Those of you who are interested in evangelical theology may find it interesting to know that one of the important early works of Francis Schaeffer is available on line. "A Review of a Review" states concisely what was to become Schaeffer's main theme, later known as presuppositional apologetics.

Schaeffer neatly distinguishes two approaches to the rational defense of the Christian faith:

(1) Evidentialism: "I believe in God because of the evidence (from observing nature, etc.)."

(2) Presuppositionalism: "I believe in God because, without it, I can't believe or understand anything else."

Though denying that these contradict each other, Schaeffer favors presuppositionalism with a twist: Nobody ever has a completely godless worldview. If you don't believe in God, you still can't help believing in some of the things that belief in God implies, such as the value of life and the usefulness of your own mind. If you really didn't believe in God at all, life would be pointless, incomprehensible, and hopeless. But God doesn't normally let you get that far out. Presbyterians call this "common grace" and it precedes the special grace that leads to salvation.

2009
June
17

More misleading headlines about inflation

Another month, another set of CPI data, another set of misleading headlines.

We're not in a deflationary economy. We were having a gasoline price spike last year, and now we're not. When prices go up, people complain; when prices go down, people panic.

2009
June
16

Quarter century

We let an important anniversary slip by. To the best of my recollection, I became a faculty member of The University of Georgia on June 15, 1984, so yesterday was my 25th anniversary. (The retirement database, however, says I have 25.111 years of service. Hmmm...)

I had just finished the second year of a 3-year postdoctoral fellowship at the University of Southern California, and, being no fool, was trying to get another job before the fellowship expired. Baylor University was recruiting me when the University of Georgia plucked me out of their grip. I joined a newly founded artificial intelligence group led by my good friend Donald Nute. I've been here ever since.



What will Mars do on August 27?

Will Mars look as big as the full moon on August 27? No, of course. If you don't believe NASA, believe Snopes.

On August 27, 2003, Mars was a tiny bit closer to the Earth than it had been or would be again for centuries. But it gets nearly that close about every two years. (Not always on August 27, of course.)

Someone started circulating e-mail giving a distorted account of the 2003 event, and it keeps starting up again, every year.

2009
June
15

Farewell to NTSC analog television

(For brevity, I am not including hyperlinks to technical references today. Technical background is given, in detail, in Wikipedia.)

I've written elsewhere how my early interest in electronics was awakened by books and magazines about TV repair. TVs in 1965 were like personal computers today — everybody had minor problems (if only with the antenna) and was looking for ways to save money on maintenance. Tubes burned out every few weeks, and tube finding (identifying the tube based on the symptoms, without test equipment) was a fine art. To the handyman crowd, electronics equalled television.

So with the demise of NTSC analog broadcasts, I feel a bit as if I've outlived my own era. At the same time, NTSC technology is hard to feel fond of. Does anybody remember how bad TV looked back before there were any advanced integrated circuits in TV receivers? The fading? The snow? The vertical-hold control?

The truth is, although the signal is analog, your TV has been partly digital for a long time, and before that, in the 1970s, it already used advanced analog ICs that far outperformed the original NTSC circuit designs.

Contrary to the old joke, NTSC does not actually stand for "Not The Same Color." But it is a clumsy system. It has two parts: the NTSC video signal (which typically comes out of a yellow phono jack on your VCR) and the NTSC modulation (RF channel) system, which comprised channels 2 to 82 until they started cutting back.

Start with the channel systems. The VHF channels 2-13 span an enormous frequency range (about 55 to 220 MHz), and as you might guess, signals at such widely differing frequencies do not behave alike. Channel 2 often has too much range — it reflects over long distances, but unpredictably, causing stations on the same channel to interfere with each other. Channel 1 was dropped because it had a worse case of the same problem. Channels at the high end cover a shorter distance with higher reliability and require a smaller antenna than those at the low end. Then there's UHF, which used to go all the way to 800 MHz.

One of the goals of digital TV was to free up some of the channels for other uses. After all, is television the only thing we want to do with practically all the frequencies on which it is feasible to transmit? Surely not, although in 1955 or so, people thought it was. A few UHF channels were converted to other uses long ago — in fact, for a short time you could hear cell-phone calls on UHF TV sets. The new digital frequency spectrum remains a wide patchwork, but with useful gaps in it; quite a few of the original RF channels are no longer used.

Then there's the NTSC video signal. I think NTSC video will be around for a long time because, although originally hard to generate, it is nowadays easy to create (with cheap cameras and with computers), so there will continue to be an NTSC output on your digital camera and similar gadgets. But the original signal format, elaborately defined by an official standard, was a thing to behold. It was especially clumsy because color was added, in the 1950s, to an existing black-and-white format that was already supposedly using its bandwidth to the fullest.

There were no phase-locked loops in the 1940s, but every TV set was nonetheless supposed to synchronize with vertical and horizontal sync signals and, later, a 3.58-MHz color subcarrier. I'm amazed it worked at all.

Only one thing bothers me about digital TV. Because of the unpredictable time taken by CPUs to decode compressed video images, people's lips get out of sync with their voices. The perfect lip-sync that we enjoyed with analog TV may be a thing of the past.

2009
June
14

Where I work

The other day, when the campus was nearly deserted and the light was just right, I got a good picture of the Boyd Graduate Studies Center, which houses the Institute for Artificial Intelligence. Here it is:

To get to my office, go downstairs and through the lower-level entrance, then turn left. Now you know.

2009
June
13

Book-and-lens sale

I'm selling some things on Amazon, including some microcontroller books and a Canon lens. Have a look — the selection will grow.

2009
June
12

Mid-June work crunch

It's the middle of June, and the whole University has just realized that it's time to do some of the work we were going to do this summer...

I'll be back in a few days! Or maybe sooner.

2009
June
11

Two econ-observations

6% is not too high: People grumble that the recovery of the housing market is being throttled by mortgage rates that have now gone higher than (gasp!) 5.5%. Doesn't anybody remember what normal rates are like? Anything under 8% was, for a long time, considered freakishly low.


What are we to make of Microsoft Antivirus? Reportedly, some virus protection will soon be provided free with Windows. An excellent idea. But I have two concerns.

(1) We will still need independent, competing antivirus providers so that a virus can't spread rapidly unless it gets past all of them. A single antivirus package would mean that everybody's computer has the same holes. The world needs multiple antivirus packages developed separately. How to manage the interaction between Microsoft and others, I'm not sure.

(2) I hope misguided regulators don't scream "Antitrust!" and demand that Microsoft stop including this vital component with the OS, the way they did with web browsers. If those people were running the auto industry, you'd have to buy your headlight bulbs separately from your car...

2009
June
10

Congratulations to me...

On Wednesday afternoon, I took a computer program I had been working on for a long time, and in about 45 minutes, made it run 20 times faster.

I did this by changing a search algorithm. The details are of course proprietary, but the point is, a faster computer can double the speed of a computation, but a smarter programmer can increase the speed much more than that.



The new Tate Student Center

The new wing of the University of Georgia's Tate Student Center is open. All I have are cell-phone photos:

This monumental building captures the feel of a big university, and it takes on an important architectural challenge, bridging the gap between conflicting architectural styles, specifically the elegant Georgian architecture to the north, the 1960s box-shaped University Bookstore, and the 1980s curved-box-shaped original Tate Student Center.

2009
June
9

You can't both end the recession and keep it going

Some people seem to be assuming that the parts of the recession that they like (e.g., very low interest and inflation rates) will persist after the parts that they dislike go away.

Not so. From Friday's news on Bankrate.com: "Mortgage rates skyrocketed again today ... because the employment report wasn't as bad as expected. Nonfarm payrolls declined by 345,000 in May, when investors and economists were expecting a net job loss of half a million or more. The not-as-bad-as-expected news fueled a stock market rally, and bond prices fell. As a result of falling bond prices, interest rates, including mortgage rates, went up."

A cynic would say you can't win. A smarter person would say that the invisible hand of market forces is doing its work as a stabilizing force. Almost any sudden change is automatically counteracted in some way.

2009
June
8

End of the water-cooler era

For something like ten years, we've had a water cooler (pardon me, a "GE Hot and Cold Water Dispenser") at home, with water delivered in huge 3-gallon bottles by Crystal Springs. We got it in order to encourage ourselves to drink lots of water. The tap water here is variable, and every few weeks, the city works on the pipes and we have discolored water for a day or so (yuck!), so we always want to have bottled water on hand.

We definitely do drink lots of the conveniently-available water. But I've gotten tired of changing the big bottles, especially because you have to do it right then, neither earlier nor later. No matter how much foresight you have, you can't change the bottle ten minutes (or one glass of water) before it's due. You get interrupted, and have to go out to the carport, in between serving different people's glasses of water for a single meal. It's bothersome.

This is something all machine designers should think about. Any machine that requires immediate attention at unalterable times is bad, whether we're talking about water-bottle changes, software updates, or what have you.

If I'd been designing this water cooler, it would have included a 2-gallon holding tank, so the bottle would be empty, and replaceable, when 2/3 of its contents were actually still available. Maybe bigger water coolers work that way; I don't know.

Anyhow, last night the water cooler stopped cooling, and we decided to re-assess the situation. We calculated that, including the cost of the plastic cups we've been using and the extra electricity, water in those 3-gallon bottles costs just as much as the same water in cases of 24 half-liter bottles, which are handy to keep in the refrigerator and don't require cups.

So we're getting rid of it. Who wants to make us an offer on a water non-cooler that still dispenses water, and can heat it (for cups of tea), but doesn't cool?

2009
June
7

Short notes

I've just invited several old friends to read the Daily Notebook, but if they're not computer programmers, they're probably going to be bored. We're having a dull month. Look at previous months — that's where the good stuff is.

If you had bought GM stock in spite of my advice, you could have done pretty well as a day trader, because it was up something like 40% the next day. But will it last?

Yesterday's University of Georgia computer network failure was caused by a problem with a transformer in the enormous UPS that powers the computer center.

Today's C# oddity: In a Windows.Forms.TabControl, the individual TabPages do not have a Visible property. You can hide them by doing a TabControl.Items.Remove, after which each hidden TabPage continues to exist but is not on the TabControl, so you can add it again when you're ready for it.

2009
June
6

University off the Internet

As I write this (Friday at 5:30), the whole University of Georgia has been off the Internet for two hours. I don't know why.



Want more disk space? Disable hibernation

Want a couple of gigabytes of disk space, or more? Disable Windows Hibernation.

The setting is in Control Panel, Power Options. If hibernation is enabled, there is a hidden file called HIBERFIL.SYS equal in size to your system's RAM, which nowadays is probably several gigabytes.

We did this today to gain disk space on a server that had been configured with a 20-GB boot partition.



APC PowerChute under Windows Server 2003

If you have an APC uninterruptible power supply, you probably have a CD with free software for monitoring the power situation. But the software doesn't work under server versions of Windows.

We made it work under Server 2003 by just setting compatibility mode. Right-click on the program in the start menu, choose Properties, and set Windows XP compatibility mode.

2009
June
5

A disconcerting moment with Vista Service Pack 2

I downloaded Windows Vista Service Pack 2 and installed it on my test machine. On rebooting, the test machine had lost its Windows activation and was running in a restricted mode of some kind, with the desktop theme changed to "Classic" (including the word "Start" on the start button).

I rebooted again, and it apparently recovered, although I haven't tested it very extensively.

2009
June
4

Computers that age gracefully?

Returning to yesterday's thought, we now have personal computers that wear out before they become obsolete. In my experience, drive C is the most failure-prone component, followed by the power supply and then the motherboard. (I don't try to diagnose components on the motherboard.)

And I think this situation is going to continue. We no longer need a new computer every 3 years. We'd like a computer that lasts 10 years.

That means we need reliability statistics. Who will gather and report them?



Should you buy General Motors stock?

[Updated.]

Today I heard someone asking if they should buy General Motors stock. Well, actually right now you can't buy GM; it's not trading. [Actually, you can, but the symbol has changed from GM to GMGMQ and it's no longer on the NYSE.] Should you buy it very cheap (currently 61 cents a share) on the ground that it has nowhere to go but up?

No. The reason it's cheap is that most investors don't think it's going to come back up. If investors thought it was going to come up, it would already have done so!

I've just given you one version of the "efficient market hypothesis," which is that in a free market, current prices already reflect all available information about the future. So why does the stock market go up (more than inflation) over the long run? Presumably, most businesses do better than people are willing to bet.

2009
June
2-3

Computer adventures

Backup battery On Sunday afternoon I installed new UPSes on our desktop computers, and both of them had lost their CMOS (BIOS configuration) settings when they booted back up.

Note that these computers were both about 6 years old. (And not out of date! They are both 2.4-GHz, single-core, and of course they have bigger disk drives than originally.) Their backup batteries had run down and were easily replaced with common CR2032 lithium cells (see picture).

One of them had a lot of trouble booting up, and it turned out that its drive C (also 6 years old) was sometimes not showing up in the BIOS. We went out and bought a new drive, did a clean install of Windows XP Professional, and have been installing software ever since. That's why you haven't heard much out of me.

I also replaced the power supply, which had become noisy, and the room no longer sounds like an aircraft is revving up somewhere nearby!



One more note about BackgroundWorker

A quirk of the C# BackgroundWorker that bit me the other day: An unhandled exception in a BackgroundWorker is not passed to the main program. The BackgroundWorker just quits. You have to ask it why it ended by looking for an error code in the argument of the event that it raises to signal that it has ended.

2009
June
1

Editorial note

The masthead of the Daily Notebook has been cleared of flotsam and jetsam so that you have at least a sporting chance of seeing the beginning of the topmost article without having to scroll down. (At least until the table of contents gets out of hand!)



Move along, folks, the Panic of 2008 is over

I posted a rough draft of the following remarks briefly for May 30-31 and then replaced it with an astrophoto. Immediately a reader wrote in asking me to restore the deleted material. Instead, I've rewritten it, hopefully with improvements.

It's official — economic pundits are declaring that the end of the recession is in sight (see also this), and it was only 1/8 as deep as the Great Depression anyhow. It's not over, but it's not going to get much worse. We didn't starve. The economy is coming back.

But it's not going to be the same economy as it was.

Out: McMansions, conspicuous consumption, maxing out your credit card, flipping houses, "Other People's Money," careers in finance or in "business" vaguely defined.

In: Thrift, saving, debit cards, small businesses that grow gradually, careers in fields that require specific technical knowledge.

I remember a similar change during the 1974 recession, and it may have given us the computer revolution.

Also in: Using technology to lower costs rather than simply to spend the same money on more powerful machines. For example, as of Saturday, you can buy (at Micro Center) a serviceable Windows XP desktop, suitable for web surfing, word processing, and accounting, for $99 without monitor. That's a factory refurb with a warranty. It probably cuts into the market for $2000 PCs quite a bit... Wait a minute. There are no $2000 PCs any more; if you want to spend that kind of money you have to buy a Macintosh.

What's on the horizon next? Higher interest rates. And even inflation. (I've been expecting inflation for some time, and the strong measures that were taken to fight the recession will surely contribute to inflation later on.)

One of my concerns is that people will keep preparing for the Panic of 2008 long after it's over, just as some people kept preparing for the Great Depression for decades after it ended. And I call it the Panic of 2008 for a reason — it was a state of mind, not just a state of the economy.

Thrift is good, but will people be so paralyzed by fear of another recession that they rent houses they should have bought, sock money away in 0% savings accounts for inflation to nibble away, deny themselves much-needed education, and continue preaching that it is morally wrong to borrow money regardless of the reason?

Or will they cling to what is good about the new culture — thrift, humility, and an emphasis on producing goods and services of real value rather than status symbols or financial tricks — while adapting to changing conditions?

One of the most important adaptations to make has to do with investments. During times of inflation, it is better to hold stocks or real estate than cash or bonds. It can even be advantageous to be in debt if the interest rate is lower than the rate of inflation, which is probably going to happen temporarily with some mortgages and student loans.



How to make it all stop
Cancelling a C# BackgroundWorker process

I recently mentioned the BackgroundWorker class in C#, for event-driven multithreaded programming.

What do you do if you want your program to have a "stop" button? The idea is that the "stop" button becomes visible as soon as the long computation starts; the long computation runs on another thread; and the "stop" button disappears when the computation finishes. If you click "stop" while the computation is running, it disables itself (so you can't click it any more), changes its label to "stopping..." and causes the computation to stop as soon as possible.

How to make this work turned out to be rather involved. (I did it on Friday.) There is no built-in way to kill a BackgroundWorker thread. BackgroundWorker has a CancelAsync() method and a CancellationPending property, but these amount to nothing more than a flag and a method to set it. The flag does not actually cancel the process. I chose to use a plain boolean variable in the main form class instead. So the "stop" button sets this variable to true, and the rest of the time it is false.

The next task was to make the computation look at this boolean variable frequently and bail out if it's set. If the computation had just one main loop, I could have checked it there, but my computation is complicated (it's a natural-language-processing system).

Clearly I faced two problems:

(1) Find all the computations that can take appreciable time;
(2) Make them look at the cancel flag periodically, and exit quickly if it is set.

Here (1) is drudgery, of course, but (2) is the interesting part.

I did not want to make all of the other classes refer to a variable in the main form, because the classes were designed to be reusable and largely independent of each other. They're not even supposed to know there's a main form.

What I did instead was to equip every potentially time-consuming method with a ref bool argument named cancelling, and alter its main loop(s) to bail out if cancelling is true. By using ref I pass a pointer to the memory location of the variable, so as to get everybody looking at the same thing rather than copies of it.

The compiler, of course, immediately told me which higher-level routines also needed to have cancelling passed to them as an argument. And so on up the tree, all the way back to the main form.

The code looked something like this:

public sometype Method1(List<something> somelist, ref bool cancelling)
{
   foreach (something x in somelist)
   {
      if (cancelling) break;
      ... do the processing ...
   }
}

public sometype HigherMethod(List<something> somelist, ref bool cancelling)
{
   Method1(somelist, ref cancelling);
   Method2(somelist, ref cancelling);
   Method3(somelist, ref cancelling);
   ...
}

This looks clumsy, but I recommend adding a cancelling argument to every reusable method that can take a long time to execute. It comes in handy.

- - - - -
If what you are looking for is not here, please look at previous months.

If you'd like to show your appreciation of the Daily Notebook, please consider making a contribution to my department at the University of Georgia. Thanks!