Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,827 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,866 people online right now. Registration is fast and FREE... Join Now!




Help with my thread?

 
Reply to this topicStart new topic

Help with my thread?

gabehabe
1 Oct, 2008 - 09:47 AM
Post #1

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,551



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Hey~ I'm working on my Twitter application (I don't know if you've already seen it, it's here if you want to see)

I had this feature working, and then I changed the code a little. Now, I can't remember for the life of me how to get it working again.

First off, I initialise "latest" on the main form's load event.

Then, in the thread, I call the function to update the "friend updates" panel (check the project thread) to add the latest to the top if it isn't already there.

So, here's the code which is being called via the Invoke() method of my panel:
csharp
	void UpdateIt()
{
Twitter.Tweet check = Twitter.GetLatestUpdateFromHome(this.username, this.password);
if (this.latest.Name != check.Name && this.latest.Content != check.Content)
{
int y = 0;
foreach (Control ctrl in this.FriendUpdates.Controls)
{
y += 100;
ctrl.Location = new Point(ctrl.Location.X, y);
}
Panel p = new FriendPanel(latest.Name, latest.Content, latest.Picture);
this.FriendUpdates.Controls.Add(p);
this.latest = check;
}
}

Basically, I'm aiming to move them all down by 100 (their height) and add a new one to the top. That looks fine to me~
The problem is that the if statement never seems to be entered. (I've come to this conclusion by putting a MessageBox before/after the if statement~ the first is shown (indicating that the method is being called correctly) but the if isn't being entered.


Thanks in advance
-Danny
User is online!Profile CardPM
+Quote Post

Jayman
RE: Help With My Thread?
1 Oct, 2008 - 10:42 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,956



Thanked: 43 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
What data type are the Name and Content properties?

Is Twitter.GetLatestUpdateFromHome returning a value?
User is online!Profile CardPM
+Quote Post

gabehabe
RE: Help With My Thread?
1 Oct, 2008 - 10:47 AM
Post #3

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,551



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Name and Content are both strings, which are stored in a struct called Tweet.

GetLatestUpdateFromHome() returns a Tweet.

It is working, I've checked the return values~ I tried using
MessageBox.Show(latest.Name) just to check, and I got the result that I expected~

I just don't understand why it's not entering the statement~
User is online!Profile CardPM
+Quote Post

Jayman
RE: Help With My Thread?
1 Oct, 2008 - 11:07 AM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,956



Thanked: 43 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
What are the criteria that defines when it should enter the IF statement?

Currently, if both the Name and Content don't match that is the only way it will enter the statement. If you put a break on the IF statement, what are the values contained in:

this.latest.Name
check.Name
this.latest.Content
check.Content

If you can post a screen shot of the Autos window when it hits the break, so I can see exactly what the values are that would be great.
User is online!Profile CardPM
+Quote Post

gabehabe
RE: Help With My Thread?
1 Oct, 2008 - 11:15 AM
Post #5

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,551



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Sorry, I'm a dumbass at the best of times. I've figured it out.

It's because it was me posting different updates each time, checking it, right?

Well, look closely at the if statement. It looks for the name AND the content to be different. In other words, I'm posting a test update, and it's seeing my name from the last post, too~

How stupid can I be?

Thanks anyway~
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 03:38PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month