Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-02-2011, 04:03 PM   #1
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
any C# programmers on here?

Please disregard the two For Statement they're wrong and outputting multiple ListID entries of the same thing. That's the problem and I need help fixing it. The MakeReq function has nothing to do with my problem its just holding values like an array does.

Code:
if (listId.Items.Count != 0 && listCell.Items.Count != 0)
        {
            for (int a = 0; a < listId.Items.Count; a++)
            {
                for (int b = 0; b < listCell.Items.Count; b++)
                {
                    lblID.Text = listId.Items[a].ToString();
                    MakeReq(txtWebUpdate.Text + listId.Items[a].ToString() + 
                        "&ire=1", listCell.Items[b].ToString());
                    //System.Threading.Thread.Sleep(5);
                }
            }
        }
this is the output i'm trying to accomplish (domain, listID, presetString, listCell)

store.domain.com 101 &ire=1 sec01
store.domain.com 102 &ire=1 sec02
store.domain.com 103 &ire=1 sec03
store.domain.com 104 &ire=1 sec04
store.domain.com 105 &ire=1 sec01
store.domain.com 106 &ire=1 sec02 <- ^ notice how listCell started over for the last two entries. that's because listCell only has 4 entry so it continuously loops applying secIDs until all ListIDs have been processed. So there maybe 500 ListID and only 20 listCell secIDs, which means listCell will just loop within itself applying the same secIDs from the top of its list down, again and again.

it's a simple concept, but you won't believe how many C# programmers are clueless as to what i'm trying to accomplish.
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 05:06 PM   #2
tical
Confirmed User
 
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
here you go, just remove/replace the temporary stuff w/ your stuff

Code:
            List<string> listId = new List<string>();
            List<string> listCell = new List<string>();
            listId.Add("id1");
            listId.Add("id2");
            listId.Add("id3");
            listId.Add("id4");
            listId.Add("id5");
            listId.Add("id6");
            listCell.Add("cell1");
            listCell.Add("cell2");
            listCell.Add("cell3");
            listCell.Add("cell4");

            int listCellCounter = 0;
            for (int x = 0; x < listId.Count; x++)
            {
                Debug.WriteLine("something " + listId[x] + " " + listCell[listCellCounter]);
                if (listCellCounter == listCell.Count() -1)
                {
                    listCellCounter = 0;
                }
                else
                {
                    listCellCounter += 1;
                }
            }
output looks like this:

something id1 cell1
something id2 cell2
something id3 cell3
something id4 cell4
something id5 cell1
something id6 cell2
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 05:07 PM   #3
nikki99
Supermodel
 
nikki99's Avatar
 
Industry Role:
Join Date: Nov 2004
Location: Sodoma & Gomorra
Posts: 22,890
I failed at c++ at university
nikki99 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 05:09 PM   #4
WarChild
Let slip the dogs of war.
 
WarChild's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Bermuda
Posts: 17,263
Tical beat me to it.
__________________
.
WarChild is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 05:15 PM   #5
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
tical THANK YOU! ... been at this for over a week.

another question is System.Threading.Thread.Sleep() the best method for pausing/sleeping? I used it earlier where trying to debug and it felt like it was hang the app.

Last edited by acctman; 09-02-2011 at 05:19 PM..
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 05:51 PM   #6
tical
Confirmed User
 
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
Quote:
Originally Posted by acctman View Post
tical THANK YOU! ... been at this for over a week.

another question is System.Threading.Thread.Sleep() the best method for pausing/sleeping? I used it earlier where trying to debug and it felt like it was hang the app.
If you've got the Thread.Sleep() in a Form it will hang your app. I use it to pause / slow down threads all of the time. You just have to use it the right way to avoid making it seem like it's hanging your app.

If you're calling something like:

void dowork
{
// some code
// loop w/ sleep
// other code
}

Then "other code" won't execute until the loop w/ sleep is done, so if there are a ton of listids then it might seem like it's lagging. Plus your form is going to get "stuck" during each sleep iteration.

If you want to have it run in the background without having that error. Then do something like this:

void listidloop
{
// your loop code w/ thread.sleep, etc.
}

and in the function you're calling it from (form or other class):

Thread t = new Thread(listidloop);
t.Start();

That way it operates in a separate thread and doesn't lock up your form. The problem here is if the listidloop function is trying to update the form form (ie, textbox1.text = "", etc) then you're going to get a cross thread error and will need to use delegates/invoking for this.
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 06:05 PM   #7
WarChild
Let slip the dogs of war.
 
WarChild's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Bermuda
Posts: 17,263
Quote:
Originally Posted by tical View Post
If you've got the Thread.Sleep() in a Form it will hang your app. I use it to pause / slow down threads all of the time. You just have to use it the right way to avoid making it seem like it's hanging your app.

If you're calling something like:

void dowork
{
// some code
// loop w/ sleep
// other code
}

Then "other code" won't execute until the loop w/ sleep is done, so if there are a ton of listids then it might seem like it's lagging. Plus your form is going to get "stuck" during each sleep iteration.

If you want to have it run in the background without having that error. Then do something like this:

void listidloop
{
// your loop code w/ thread.sleep, etc.
}

and in the function you're calling it from (form or other class):

Thread t = new Thread(listidloop);
t.Start();

That way it operates in a separate thread and doesn't lock up your form. The problem here is if the listidloop function is trying to update the form form (ie, textbox1.text = "", etc) then you're going to get a cross thread error and will need to use delegates/invoking for this.
If you're going to do it in a sepeare thread, it might be worth throwing in an application.processmessages too.
__________________
.
WarChild is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 08:29 PM   #8
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
am i doing this correctly, trying replace the pre-loaded entries from your example with my actual listboxs for loading/processing

Code:
List<string> listId = new List<string>();
foreach(var item in this.listId.Items)
{
    listId.Add(item.ToString());
}
List<string> listCell = new List<string>();
foreach(var item in this.listCell.Items)
{
    listCell.Add(item.ToString());
}


int listCellCounter = 0;
            for (int x = 0; x < listId.Count; x++)
            {
                Debug.WriteLine("something " + listId[x] + " " + listCell[listCellCounter]);
                if (listCellCounter == listCell.Count() -1)
                {
                    listCellCounter = 0;
                }
                else
                {
                    listCellCounter += 1;
                }
            }
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 09:30 PM   #9
tical
Confirmed User
 
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
Quote:
Originally Posted by acctman View Post
am i doing this correctly, trying replace the pre-loaded entries from your example with my actual listboxs for loading/processing

Code:
List<string> listId = new List<string>();
foreach(var item in this.listId.Items)
{
    listId.Add(item.ToString());
}
List<string> listCell = new List<string>();
foreach(var item in this.listCell.Items)
{
    listCell.Add(item.ToString());
}


int listCellCounter = 0;
            for (int x = 0; x < listId.Count; x++)
            {
                Debug.WriteLine("something " + listId[x] + " " + listCell[listCellCounter]);
                if (listCellCounter == listCell.Count() -1)
                {
                    listCellCounter = 0;
                }
                else
                {
                    listCellCounter += 1;
                }
            }
Actually you don't need to pre-populate a list. You should be able to use your existing collections:

Something like this, my sytax may be off a bit... but it should be clear! Hope that helps

Code:
            int listCellCounter = 0;
            for (int x = 0; x < listId.Items.Count; x++)
            {
                Debug.WriteLine("something " + listId.Item[x] + " " + listCell.Item[listCellCounter]);
                if (listCellCounter == listCell.Items.Count() -1)
                {
                    listCellCounter = 0;
                }
                else
                {
                    listCellCounter += 1;
                }
            }
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-02-2011, 10:13 PM   #10
Mr Pheer
Confirmed User
 
Industry Role:
Join Date: Dec 2002
Posts: 20,892
Remember when you copied my webcam page and left my counter code on it? That was some funny shit.

Still got that BMW you did all the custom work to?
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-03-2011, 06:20 AM   #11
Chosen
 
Industry Role:
Join Date: Aug 2001
Posts: 63,151
Asm programmer for Z80 processors here
Chosen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-03-2011, 07:44 AM   #12
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by Mr Pheer View Post
Remember when you copied my webcam page and left my counter code on it? That was some funny shit.

Still got that BMW you did all the custom work to?
Spunky! LOL that was back during the ynot irc chat. hey man what's up, how have you been? Still got the BMW, just hit 66k miles on it. I stopped customizing it after I won first place at NOPI Nationals, that's all I wanted.

Last edited by acctman; 09-03-2011 at 07:45 AM..
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.