Re: Want to sell copies of Champ?

| Index | Champ Home Page |

Posted by Christian Klauser on 2007-06-26 01:10 CET
(In reply to: Re: Want to sell copies of Champ? posted by Christian Klauser on 2007-06-18 17:01 CET)

Hi,
while waiting for your reply, I've done some research. The results are quite promising:

* void ChampMain()
* {
* * var win = new Window();
* * win.Run();
* *
* * WaitFor(win.button,"Click");
* *
* * win.label.Text = "Thanks for clicking.\nNow enter your name:";
* * win.button.Enabled = false;
* * win.textBox.Text = "";
* * win.textBox.Enabled = true;
* *
* * do
* * {
* * * var key = WaitFor<KeyEventArgs>(win.textBox,"KeyDown");
* * * if (key.KeyCode == Keys.Enter)
* * * * break;
* * * win.label.Text = "Close by pressing <Enter>.";
* * } while (true);
* *
* * win.Close();
* }

(Yes, I used the C# 3.0 compiler, thus the implicitly typed 'var's, but the application is compiled against the .NET Framework 2.0)
Using the static 'T WaitFor<T>(object,string) where T : EventArgs' method, you can block the execution of the current thread until the requested event has been raised. If the event's signature follows the .NET event pattern (2 parameters: object sender, EventArgs e), the function returns the EventArgs passed to the dynamically generated handler.

For my sample application, I used 3 managed threads:
- MAIN: runs "ChampMain"
- RENDER: processes the windows message loop
- ROUTER: routes events from the RENDER thread to the MAIN one

There, however, are scenarios that cannot be handled sequentially. The Form.Close event allows it's handlers to prevent the window from closing, but since the 'handler' (in the sequential model) only signals the MAIN thread to continue, the latter can not deterministically influence the window's decision whether to close or not: Once all event handlers have been invoked, the window checks the EventArgs object. The MAIN thread may or may not have been fast enough to make changes to that object.

Add
* using System;
* using System.Collections.Generic;
* using System.Windows.Forms;
*
* namespace SequentialWindow
* {
* * partial class Program : SequentialProgram
* * {
to the code snippet above and you have what users of a champ-to-.NET-port would see. (The "using System.Windows.Forms;" is required for the 'KeyEventArgs' and the 'Keys' enumeration)

The 'partial' keyword merges the users class with a file that would be part of a Champ project template and that defines a 'public static void Main()' in which it sets up the event router and instantiates 'Program' (so programming novices are not confronted with 'static').

I would say: Champ on the .NET platform is definitely not impossible.

Email: (hidden)


Current thread:
Want to sell copies of Champ? Christian Klauser 2007-05-29 01:36 CET
Re: Want to sell copies of Champ? Hans Salvisberg 2007-05-31 07:06 CET
Re: Want to sell copies of Champ? Hans Salvisberg 2007-06-11 02:27 CET
Re: Want to sell copies of Champ? Christian Klauser 2007-06-17 15:12 CET
Re: Want to sell copies of Champ? Hans Salvisberg 2007-06-18 02:54 CET
Re: Want to sell copies of Champ? Christian Klauser 2007-06-18 17:01 CET
Re: Want to sell copies of Champ? Christian Klauser 2007-06-26 01:10 CET
Re: Want to sell copies of Champ? Hans Salvisberg 2007-06-26 09:10 CET
Re: Want to sell copies of Champ? Christian Klauser 2007-06-26 12:49 CET
Re: Want to sell copies of Champ? Hans Salvisberg 2007-07-02 03:03 CET
Re: Want to sell copies of Champ? Christian Klauser 2007-07-08 10:52 CET
Re: Want to sell copies of Champ? Hans Salvisberg 2007-08-11 00:08 CET
hot asian modles ReaBereasty 2010-03-08 01:29 CET
celebrity hangouts in london StamnRahfam 2010-04-02 15:50 CET
party hardcore free 78 RobertNasarros 2010-05-12 05:22 CET
courtney simpson anal and piss max hardcore 11 RobertNasarros 2010-05-15 15:12 CET
mature asian hardcore fuck 57 RobertNasarros 2010-05-18 07:23 CET
hardcore gay porn tube 30 RobertNasarros 2010-05-21 11:28 CET
Newbie ToorgeRep 2010-04-23 23:09 CET
Halo ToorgeRep 2010-04-30 22:24 CET
Aloha ToorgeRep 2010-05-03 02:55 CET
Hai ToorgeRep 2010-05-04 18:35 CET

Use this form to post a followup.
Name:
Email: (optional, hidden, replies will be forwarded to this address)
Subject:   (no text)

Message:

Optional Link (uses rel="nofollow" attribute to avoid attracting spammers)
Apparently, the forum spammers don't know what rel="nofollow" does, and because
they continue to feed their trash into the forum, we have to disable the Link feature.
Please do not post any link, or your post will be deleted automatically.
We're sorry for having to take that measure.
URL:
Title:

   



| Index | Champ Home Page |

Copyright © 2010 Salvisberg Software & Consulting. All rights reserved.
Top