Results 1 to 3 of 3

Thread: First day of C# -

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    59

    First day of C# -

    G'day all,

    Today I downloaded the .net express package and did my first lot of c# coding.

    I was just wondering if anyone can take a look at the code I wrote and just let me know of any bad habits I am falling into early on (as I'd like to fix any before I get into it too much) and anythings which you think I might be doing in an inefficient manner.

    There isn't much, code, a bit under 100 lines at a guess.

    Also, what version am I using? It's the 2008 express edition.
    Attached Files Attached Files
    Last edited by Midol; Sep 11th, 2008 at 12:03 PM.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: First day of C# -

    Hey there.
    What does your application do? Ive downloaded it and looked at your code, but I havent ran the code as it seems to involve hiding windows.
    Anyhow, your code looks very good. The only two things I can see directly are;
    You've got a variable called "i" declared at class level, though it is only used in one method, so you should declare it locally in that method. A thumb rule is to keep every variables scope as narrow as possible.
    At a point in your code, you're sleeping the UI thread. At any time you feel like you need to sleep the UI thread to solve an issue, you might need to rethink your logic. However when sleeping the thread is really needed, you must remember that sleeping the UI thread is a big no-no, as it'll make the application appear as not responding for the user.
    Create a separate thread to run the code that has to be "put to sleep".
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    59

    Re: First day of C# -

    G'day,

    Yeah, so far it does nothing - just wanted to make sure I wasn't in any bad habits like I got into when I entered VB6. Not sure if you know what WoW is (Well, everyone knows what world of warcraft is) but this is just going to be a multiboxing program. Just sets the windows up, broadcasts keys to appropriate windows and makes it easy to play 5 characters at once on one machine.

    I'll make sure I remove that variable and place it where it should be.

    I wasn't entirely sure how the sleep code works, but I'll make sure I fix that up. I am considering running it a different way because of that as I wasn't aware I could create a separate thread but now that I know that would work perfectly.

    Thanks for your feedback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width