Threading with Forms

Some of our students have been having fun with threading and forms (there is a lab out there at the moment which can be solved by creating a thread which performs a task).

Threads are great, because you can send them off to do something while you get back to responding to the user, or whatever. Snag is, when another thread tries to dicker with the contents of a form this ends in tears, as the Windows system is very picky about actions like this. There is a way round the problem though, and so I've written a little sample application which shows you how to do it.

It creates a form which has a single button on it. When you press the button it creates a worker thread and fires it off in another class to do something. When the something finishes it then calls back into the form to change the text in a label on that form. You can use this as a model for whatever you fancy doing with threads. You can find the code here.

Plumb Job

Earlier this morning I was wondering how I was going to spend all this new free time that I have now that the writing on the book is finished.

This afternoon I found out. I get to clean mouse droppings out of the summer house. The pesky little rodents had made their way back in over the winter and seemed to have held a particularly messy party in my gardening gloves.

Lovely.

Gone to the beach

Most of the writing is now done. Just a few bits left to add. So we went to the seaside. I really like Hornsea. It has a faded charm that I find really attractive. Number one son and I took our cameras, and we were dead lucky because the light was lovely for photographs.

455615238
Beach front

455819287
Asset stripped

455817937
Indoor amusements

455811479
Windmills

455777154
Hornsea Mere Tea Rooms. Fantastic.

455785493
This pike is over 100 years old.

455767686
I once got a hole in one here. Snag is, it was the wrong hole....

455764279
Boats

Remember Me?

Sometimes to solve a problem you have to go and live there. And that is where I've been these last few days. Living in a book. Although I've actually done quite a lot since the last post.

  • got a media pc
  • met some ducks and swans
  • been very jealous of my father in law
  • controlled a robot vacuum cleaner with the .NET Micro Framework
  • beat Ian at table football (twice)
  • seen Laura Viers live
  • gone to the seaside

I'll catch you all up with these things as soon as all the pictures have uploaded onto Flickr.

Roomba Magic

I actually own a useful robot. Amazing. I've got some useless ones too, but this one actually does something that number one wife thinks is good. It does the vacuuming. You plonk it down in the middle of a room, give it a kick and off it trundles, bouncing off furniture and cleaning as it goes. And it does a creditable job. To be sure, we did have to clear a bit of junk off the floor to give it a free run, and it does take longer than I would, but the evidence in the dust collector is clear, it cleans.

We set it loose in the bedroom and it rumbled about for a while. When I caught up with it later it was coughing a bit, and upon inspection it had picked up a lot of dust (it had been wandering about underneath things), an umbrella cover and 20 pence. I emptied it all out, charged the battery and off it went again. The device itself is beautifully engineered. It bristles with sensors so that it really can follow a wall, detect and manage collisions with obstacles and avoid falling down stairs (it is especially good at that one). And it has a bunch of brushes and proper filters and stuff. It really is a vacuum.

The funny thing is that I didn't really select it for its cleaning prowess. I was more interested in the interfacing potential for the Micro Framework book that I'm presently writing. The robot exposes a software interface into which you can plug a computer. It works too. I've had C# programs in a Micro Framework telling the robot what to do, which is very nice.  But now number one wife wants it to clean the conservatory, so I'll have to get on with something else.

Laura Viers Sings

Indeed she does. Very well. Number one son spotted that she was appearing in York, and so off we toddled. I took the big camera, but I might as well have not bothered. The lights were a bit low and even with the camera gain turned up to 11 it was hard to get any good photos.

455761519
Laura in red (and that is a sock over the microphone)

She played mostly new stuff, which was alright by me. She does have an amazing voice and her band were absolutely top notch.

Media Friendly

Number one son was supposed to be a restraining influence. He was supposed to drag me away from temptation and stop me doing things like buying Sony Media Centre PCs, even if they were half price. Unfortunately he was no good at all. So now I've got this Sony XL-201 thing lurking under the telly and I've thrown all the silver boxes out.

And it used to work very well. It was running XP and Media Centre 2005 but of course I wanted more. I wanted Vista. Well, today I got it. We left the machine upgrading while we went up town. When we got back all looked fine, which is bad. One of Robert's rules of computers is that "Everything useful requires payment in pain".

When things seem to work OK my heart tends to sink, because it means that the bits that are going to not work are going to be swines to fix. I'd much rather have a completely black screen and nothing happening, because I can attack that up front. With this variant of the hand of fate I have to find out what is going to be wrong before I can fix it.

Well, later today I found out what is wrong. Nothing too important, just that when you turn the TV on the computer crashes. The NVidia drivers just can't handle the fact that the TV is saying hello down its HDMI connection. They show their surprise by blue screening the box. As I am pitching this device to number one wife as the answer to all our problems, the media hub to end all hubs, the thing that only needs one remote control this is a bit of a sticking point.

We have tried various versions of the drivers and all have the problem to a different degree. By not turning anything off, ever, things work OK, but I don't see this as energy efficient. Actually, I see it as darned annoying. I have a Sony TV plugged into a Sony computer running drivers downloaded from the Sony site. And it crashes when you turn the TV on. Do they test this stuff? Do they ever turn it off? At the moment the best I can do is live with it until NVidia (for I suspect they are to blame) ship something a bit more resilient.

Then this evening we went round to see Ian. Everyone beat me at pool, which is bad. But I beat everyone at table football. Which is good.

And yes, I did churn out a bunch of book pages in the meantime.

Respect

My father in law has style. He showed this by getting out some of his record collection:

455762511
Ying Tong indeed

This is the sleeve from a Goons EP that he bought many moons ago. He still has the record too. Great stuff.

Then it was back onto the motorway for the journey home. On the way we passed a lorry loaded with stuff which the sign on the back referred to as "Equestrian Bedding". We think they mean straw.

Once more for the ducks

I always know exactly what to do when you have a crashing deadline looming. You go on holiday for a couple of days. So we have. We've rumbled down to Bristol to meet up with the inlaws. And, as is our wont, we've gone to look at some ducks.

455648958
But first some nice flowers

455667153
..swan of those days

455669221
Slimbridge Mission Control

455672802
If the birds learn to read we are all in trouble

455676774
There's a kingfisher in the middle of this. Yes, really.

455696134
Lovely plumage

Then it was back to the ranch. I did get around to writing a few pages though...

In search of robot vacuums

The .NET Micro Framework book is coming along OK. And I've managed, by means of some clever wangling, to get myself permission to buy a robot vacuum cleaner as part of the job.

The reasoning is that we need something to control with our Micro Framework device, and the Roomba vacuums from Irobot look fun. And you can control them via a serial port. So I've been digging up references and making plans. Should be fun.