How to run a code when a given user tweets something?

Hi!
I am new to using this API so I could really use an example code.
I'd like to know how to run a piece of code when a given user Tweets something.
If some one could give me an example program, something really small so I can understand how it works, It will be much appreciated.

I want to make a little program that gives you notification when a select user tweets something without having to log in.

Hey, thanks for the reply!
But I am a bit confused.
Can I specify which user to fetch tweets from?
And can I just use Twitter Application Credentials (consumer key, access token etc.) instead of user credentials?

Tweetinvi does not provide this feature by default because it is not provided by Twitter.
All depends on what you want to do. If you wish to receive the tweets from users that you are following, you need to use the UserStream and use the code above.
If you want to limit the scope of users you want to follow, just create a list of users you want to follow and check if they sent a message or not.

I think this is a good suggestion and will implement this feature for the future version of the UserStream (but not in the nearby future).
I have consequently added a feature to the list of work items that you can find here :
https://tweetinvi.codeplex.com/workitem/1936.

And can I just use Twitter Application Credentials (consumer key, access token etc.) instead of user credentials?

No you can't and never will be able to because Twitter requires the user to provide both the Application and the User credential. There is now way to only provide the application credentials for this kind of feature.

Problem 1 - A local variable named 'sender' cannot be declared in this scope because it would give a different meaning to 'sender', which is already used in a 'parent or current' scope to denote something else.

Problem 2 - The program would freeze once I run the command above.

Questions:

Question 1 - Is my way of writing the tokens and keys wrong? If so Did I mess up the order or what I had to write?

Question 2 - Do I need to run the code once or do I need to keep refreshing it. I would imagine that I would have to run it once since it constantly fetches data from the stream.

Question 3 - Is it normal that my Program Freezes? Can I run the code above and still maintain functionality for the rest of the form? (I am using Windows Forms)

PS - Currently I am trying to Bind the code above to a button.
PSS - I used Console Write Line above to keep it simple.

Problem 1 - A local variable named 'sender' cannot be declared in this scope because it would give a different meaning to 'sender', which is already used in a 'parent or current' scope to denote something else.
sender already existing here us.TweetCreatedByAnyone += (sender, args) => it is in fact the sender of the event not the sender of the tweet. The sender of the tweet can be retrieved like that
args.Value.Creator.

Problem 2 - The program would freeze once I run the command above.
The program does not freeze. It basically waits a reply for the stream to close. While the stream is open you are receiving information from Twitter.
You can make the stream run in another thread if you wish a program to run at the same time.

Question 1 - Is my way of writing the tokens and keys wrong? If so Did I mess up the order or what I had to write?
No it seems perfectly alright.

Question 2 - Do I need to run the code once or do I need to keep refreshing it. I would imagine that I would have to run it once since it constantly fetches data from the stream.
Yes as it is a stream you just have to run it once. Also you can pause or stop the stream. In which case you will have to resume/restart it.

Question 3 - Is it normal that my Program Freezes? Can I run the code above and still maintain functionality for the rest of the form? (I am using Windows Forms)
As I said before, you need to run your code in a separate thread. Consequently if you are using Windows Forms, simply put this code in a BackgroundWorker.

PS - Currently I am trying to Bind the code above to a button.
There should not be any relation. If your code is bound to a button. Create a command calling a function that uses a background worker containing your code.

PSS - I used Console Write Line above to keep it simple.
In that case, a new thread would be more appropriate than a Background worker.

Don't worry the forum is here to respond to the developer's questions :)

1 - How long does it take for the API to Fetch data
It should take approximately less than a second to receive the information from the stream.

2 - Did I (again) borked something up in my code?
No you did not and the code you wrote is good.
By looking at the code I can see 2 things going wrong

The user screenName you provided is incorrect. Twitter differentiate the ScreenName from the UserName. The username is what you see on twitter. The screenName is a unique identifier of a specific user. They can be different. So please verify that you are
using the ScreenName.

By writing the code I did not thought about case sensitivity. It implies that if the user screenName does not match the casing provided in the list, it will fail. Here is the updated code.

Okay, so I tried and tried and changes stuff around to get it to work, but I just wont do anything.
I am going to post my entire code here and only rename tokens and twitter user and I will use a celebrity twitter screenName.

In this case I choose @billgates, when ever he tweets something it should load google but I obviously borked something once again and it just wont,
I renamed some of the stuff above, mostly strings.
On my end I am using a test Twitter account to try my program, and I tweet random stuff to see if the thing would work, it wont.