May be we can't expect this in the right order? as they are "Threads!"?
You hit it spot on. Threads are scheduled by the system when to run and for how long. So what you are observing now is the expected behaviour, eventhough there might be circumstances where the order would be what you presumed first .
Did you also try the third alternative from the SO post I referenced in my solution attempt?
PS: Skip the Mr. stuff, we're all peers here on CP.
"I had the right to remain silent, but I didn't have the ability!"
I'm just letting the monkey go off my head at the moment as the code works with the ParametereizedThread start. Packing the code and sending it to my mates.
Once done, will come back to explore the method that you pointed out. cheers! Mr. Manfred
Threading is not deterministic in the order of execution unless you add constructs to synchronize your threads, e.g. Thread 2 waits for completion of Thread 1 before it starts, Thread 3 waits for completion of Thread 2 before it starts, etc. But that would defeat the purpose of threading, if you create threads to allow parallel execution, but then you serialize all of their execution.
(On a multi-core machine, they can even be scheduled to execute physically at the same time, which opens up a can of even more indeterministic behavior )
The problem is the lambda expression, it references the variable i of the outer method at the time of the thread execution, and that is likely after all threads are created. This is not like a passed parameter that gets copied at the time of the thread creation.
Try creating a thread that takes a parameter and pass the i there, this should resolve the issue.
No the problem is that you are using threads and you think that there should be an order.
It is simple - stopping thinking that. There is no order. It doesn't matter how you create them nor execute them - there still is no order.
If you want an order then you must assert that order yourself into the code.
HOW you do that depends on what you actually want to acheive. It could be as simple as just ordering the final set after processing of all the threads completes. Or providing a bucket into which each thread puts its result.
Sometimes the execution order does not matter, but the publishing of the result (e.g. if your processing takes significant time before results are available). In this case you should spinup the threads and let them execute in any order as they will, but when the results are available wait for the completion of the "previous" thread and then publish your results.
Using a pattern like this would allow to use the parallel execution of the long processing and still have the serialized behavior at time of the publishing of the results.
In last week, I wanted to make a presentation viewer(Slide show) using C#.
I went through MS-PowerPoint and its done but licensed(So not of my use).
MS-PowerPoint Viewer(No support in C#).
Then LibreOffice and OpenOfficeOrg- Too much complicated to use, having errors in libraries.
So what may be the best way to implement a presentation controller in my form.
I can use C# or C++.
Remove this post. It's VERY unlikely that the person you're addressing this to will ever see it and the only people interested in your email address are the spam bots that scan these forums pretty regularly looking for email addresses to send all kinds of spam to.
Post your question in the forum at the bottom of the article that you're talking about.
I am having issues with maintaining info when person uses browser back button. I work for a company which is an online traffic school course. The issues I am having is say a student starts on lesson 1. Within lesson 1 there are 10 pages of content that they must read and click Next button to go to next page. Once they then have read all 10 pages, then they go to a quiz where they are given one question at a time (there are 5 questions). They click Next button to move to each question. Once they have answered all questions, then they go to a grade page. If they passed, then they click on continue button to go to lesson 2. Then onto quiz for lesson 2. This part all works great and if they click our programmed Back buttons everything works great as well. The problem is if they go from say lesson 1 all the way to lesson 3 (just an example) and they decide to use the browser's back button to go all the way back to lesson 1, everything tends to get messed up. Since we are driving off of class Student which contains current lesson num, current page num, current question num, once we advance further in the course these values get updated. My problem is that when the student continuously clicks the browser's back button the lesson num, page num and question num (and other content) does not follow suit to what it was. I am not sure why, but the pages are not being cached. Is there anyway to maintain the lesson num, page num and question num as the student clicks browser back button? Meaning as they click back to quiz from lesson 2, it shows lesson 2 (it is currently showing lesson 3 since that is how far have advanced) and same with the lesson pages that they must read. I have tried to use hidden input, but it does not seem to work correctly all the time. Any ideas???
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
As others have said, this really should be in the ASP.NET forum. However, some food for thought for you - what you are looking at maintaining is effectively the maximum point they have reached. To this end, you might want to use a combination of the user Session and a database (if the user can log out and log back in) to hold this value.
I was brought up to respect my elders. I don't respect many people nowadays.
Our database maintains current lesson, page, question, advanced (furthest point reached) lesson, page, question, and max (furthest point to reach) lesson, page, question. As the student moves forward, the current and advanced values get set. For example, when the student views the lesson the .ASPX page displays lesson # and page #'s available in lesson with current page highlighted and the lesson content (the verbage they must read to pass the quizzes) for that lesson/page combo is displayed. As they move forward in the pages, the highlighted page # changes and the lesson content changes. Once they reach the max page for that lesson and they click on Next button, they then go to quiz. On quiz ASPX page, the lesson and question # are displayed (lesson # and question # are set by current lesson and current question values) as well as the associated question and possible answers. Once student then goes to lesson 2, current lesson # = 2, current page # = 1, advanced lesson # = 2 and advanced page # = 1. Now I have noticed different things happen based on what browser is being used. For example in Firefox, once student goes all the way through lesson 1, takes lesson 1 quiz, passes and goes to lesson 2. Now if student clicks browser back button everything seems to be ok, it appears to be cached. If student clicks browser back button to lesson 1 quiz question 2, everything seems to be ok. That is it shows Lesson 1 Question 2 with the appropriate question and possible answers (with their answer selected). However, if student goes all the way back to lesson 1 quiz question 1, it displays Lesson 2 question 1 but with lesson 1 question 1 question and answer. Now if student clicks on our programmed Next button, the program now thinks we are on lesson 2 quiz and next shows lesson 2 question 2 along with a question and possible answers that are indeed from lesson 2 and none of the answer radio buttons are set since have not taken lesson 2 quiz.
I would have thought that everything would have been cached. So no matter how many times I click browser back button from my furthest point it would be showing exact pages I went through in reverse order, but this is not the case. Any ideas???
I have a couple of questions, half C# related, the other half, less C# related, but more related to embedding URL in C#, thank you for your attention.
I'm writing a console app (in C#) that is supposed to pop up the default mail software, fill in the recipients, subject and body.
this data is acquired from a txt file the app processed.
To do that I start a process (IEXPLORE)
and give it the @"mailto:...", A regex I created from the processed data.
problem is, the body of the text does not take \n seriously and well, basically I have one long line where five should be.
one of my questions is, how do I get a URL to produce a line break?
A second issue is that the app is also supposed to attach the attachments, whose full local path has been processed from the latter mentioned txt file.
i used the &attachments="c:\..." and well, no attachments..
Now for the more C# related part...
the app has two bi-products :
It opens a console windows which needs to be manually closed
IT opens an explorer window that needs to be manually closed
I am a novice programmer and still do not know much about threads.. I understand that I will have to use them somehow, could someone point me in the right direction?
You don't. A URL is a continuous sequence of characters, and should remain so - plus, if you could break the line, where would you break it? Just because it fills a line of text on your monitor doesn't mean that it won't wrap when viewed on a tiny screen smartphone.
Now, as for threading, a simple way to spawn off your work is to use the Tasks Parallel Library (TPL). This[^] is a great place to get started.
I was brought up to respect my elders. I don't respect many people nowadays.
My first thought is, that Color has a value 0 that is different from null. The next thought is, if Color is a reference type, == compares the references (as opposed to the content). You may have to call .Equals()
You could leave out the last condition for a test and check the Color value of the returned entity.
I create a WCF web service that contains this method in service.svc:
public int positionGPS (_latitude string, string _longitude)
/ / Send the ordinate DB
DAL.GPSEntities bd = new DAL.GPSEntities ();
/ / Table of the database table position
Pos = new TablePosition TablePosition ();
this method will be called back for a pda, gps coordinates
then they saved in the database.
I want to know how to send these coordinates to another application winforms for tracing in real time in maps.
I know there is a method to use the socket, but I do not know how to apply in wcf, wcf then my service will be housed in the IIS server.
and in our case winforms application (the client socket that many) also PDAs.
and thank you in advance.
The drivers for UARTS SOMETIMES tell the truth, and SOMETIMES tell lies.
A bluetooth adapter plugged into a USB port will tell the system that the max speed is 115200
If you set the baud rate to 1200 (just to make sure, that's "twelve hundred", I didn't leave out a zero) the real speed will still be 921600.
In fact, C# and windows will not allow you to set a rate above 115200. No matter what port speed you set, you will still get data at 921600.
The drivers for this FTDI USB UART produce different observed behavior. Don't understand it, but for whatever reason, I AM able to place the number 921600 as the speed when accessing the wired UART using FTDI's cables, but NOT able to do this with a bluetooth adapter.
All the while, they will both have, evidently, the same speed.
Anyone who does not understand this is just not Hi-Tech