|
|
I have this code:
public void mtdProgressbar() {
prgsBar.IsIndeterminate = false;
prgsBar.Orientation = Orientation.Horizontal;
prgsBar.Minimum = 0;
prgsBar.Maximum = short.MaxValue;
prgsBar.Value = 0;
double value = 0;
prgsBar.Visibility = Visibility;
UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(prgsBar.SetValue);
do
{
value += 1;
Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background,new object[] { ProgressBar.ValueProperty, value });
}
while (prgsBar.Value != prgsBar.Maximum);
prgsBar.Visibility = Visibility.Hidden;
}
But i can not create the Thread do fill progressbar, do not work.
The code:
.
.
.
else{
System.Threading.Thread trd = new System.Threading.Thread(new System.Threading.ThreadStart(this.mtdProgressbar));
trd.IsBackground = true;
trd.Start();
mtdTest();
}
I'm using C# and Wpf
|
|
|
|
|
Threads can be tricky, what you are running into is a problem with access.. threads by default can not access the ui to update a progress bar because that may create a deadlock.
For the background worker there is a function built in for report progress, but it is limited to only allow for simple updates.
You can however, get around this requirement by doing
.Invoke((Action)delegate() which allows safe access to the ui through a delegate.
I have used this method to update multiple labels, etc.
That should do the trick.
=)
|
|
|
|
|
Forbiddenx wrote: You can however, get around this requirement by doing
.Invoke((Action)delegate() which allows safe access to the ui through a delegate. Hi, isn't the OP already doing this in his code:
do
{
value += 1;
Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background,new object[] { ProgressBar.ValueProperty, value });
} ?
Of course, the OP didn't disclose the code for 'updatePbDelegate, or show where it's created. In this case I think the problem is elsewhere (see Dave K.'s response).
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
Yes, I do see invoke but it does not look like its used correctly.
It looks to me like his code is trying to access the progress bar ui directly and outside of the invoke.
It looks like he is setting a lot of values, my guess is some of those values are on the ui and that is what is crashing everything.
I think he is going to have to re-write how this works..
=)
|
|
|
|
|
You don't put the progress bar in the background thread. It MUST stay on the UI (startup) thread. Your work goes in the background thread and then Invokes a method that updates the progress bar on the UI thread.
|
|
|
|
|
See here[^]
It's from one of the CP members... (btw)
hope this helps
|
|
|
|
|
I'm in my third year of a software development course and will soon be tasked with completing a project to demonstrate my knowledge so far in programming.
I have decided to pick c# as the language as I'm more confident with it and my ideas so far are either a website with a database and/or a shopping cart or else an application like a movie library that has a database and capabilities to update info from the web.
The spec for the project is vague in terms of features and functions as I'm just going by what I've learned in the last three years.
I would be grateful if anyone could give me some feedback on my ideas or any new ideas they may have.
Thanks for your time
|
|
|
|
|
Depending on how long you have....
C# and unity go nice together..
=)
|
|
|
|
|
Choose something that you have an interest in, so that your knowledge can help you design the program. It is impossible to suggest much more as we have no idea of your experience. You could look at the CodeProject Articles section[^] for some further ideas.
Veni, vidi, abiit domum
|
|
|
|
|
Go with Richards idea, my son did his on scuba diving, his hobby at the time.
If you can't think of something then try and find a friend who runs a small business and ask then for their most painful paperwork job then try and automate it. Beware you may lose that friend, birthing your first LOB solution is a painful exercise for all involved.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi johnmolo,
You can chose any one of the projects you mentioned.But take care of following points.
1.Use coding standards.
2.You should include all the OOPs concept in your project.
3.Database standards should be followed.
4.Use MVC architecture for designing.
5.Choose a professional looking design, no need for a complex design.
6.Try not to use any external API's since it may cause problem at any time.
Happy coding and wish you all the best for your project
|
|
|
|
|
Quote: 6.Try not to use any external API's since it may cause problem at any time.
What if someone would like to do payment integration. External API is the only bridge that can help Software developers to work beyond the limit of their existing software. You can add more functionality and more features. My personal opinion is to use already build application (API) instead of rebuilding the same. If we have Image processing library why should i create my own for even my small project.
I am not against you but always there is two side of coin. You may have some bad experience with external API's.
Thanks
-Amit Gajjar
|
|
|
|
|
Hi Amit,
Thanks to point out the mistake.What i really meant was not to use complex APIs since it may affect working of project ( I had a bad experience ).
|
|
|
|
|
PM88 wrote: 4.Use MVC architecture for designing.
Why? One of the worst pieces of advice for someone is generally "use pattern x on this project" before the project requirements have been defined. You should never go into a project having picked patterns to follow because you end up constraining your design and you might have to contort it to fit an unsuitable architecture.
|
|
|
|
|
Agree, decision of architecture and design pattern is vary by project.
Thanks
-Amit Gajjar
|
|
|
|
|
Hi,
Sorry for the mistake.I defined this one since it was mostly used among Dot Net developer these days.I would like to take back this point.
|
|
|
|
|
It's used commonly by .NET web developers you mean. WPF and Silverlight developers tend to steer clear of it, Winforms developers will not have done much with it and server side developers will have steered clear of it.
|
|
|
|
|
There are many application in the market. if you do something different that people may not have seen before that may impact more. If you want to earn more credit compare to your other class friends you need to think beyond the usual application development. Your idea is not bad but you can find many opensource application in the market with the shopping cart or database applications.
I suggest you to work in any opensource community to provide them help to create some modules or may be some functionality. But first get approval from your project guide. Creating project from scratch is not the only option. First you need to identify any of the community and the functionality they are looking for.
Second option is to work on some algorithm that are not implemented in C#. You can also convert any existing C/C++ library and publish as an opensource. that will also gives you credit from many developers.
But the primary thing is to convince your project guide.
Thanks
-Amit Gajjar
|
|
|
|
|
I would go for the movie database. A webshop application can become very complex.
For extra credit I would create it more as a media library that can also contain books and CD's for example. (and then tie those together).
Also if you're allowed, create something like a flashy WPF (or winforms) instead of web. It removes the problems of sessions, client/server code etc...
Don't get me wrong, don't set the level too low, but my experience is that applications tend to be more complex than you imagined them to be, especially when you're still junior.
hope this helps.
|
|
|
|
|
My file contains data like:
First name: ahmed
Last name: nasser
City: giza
i created a flat file schema to parse this file, but the element store all the line.. such as
<Fname>First name: ahmed</Fname>
<Lname>Last name: nasser</Lname>
i want the element to store only the value without the label ..to be like this:
<Fname>ahmed</Fname>
<Lname>nasser</Lname>
How To do that using Flate File Schema.. BizTalk?
|
|
|
|
|
The script needs to visit a series of game retailer websites and input some keywords into their search boxes. Then it yields the product results sorted by price in an HTML table in a separate page. The resulting HTML table is a list of the accumulated results.
The goal is to obtain a sorted overview of the total result set, sorted by price so that the cheapest version of the game (lowest price) is visible on the top of the list.
How would I begin coding this?
Is another implementation language recommended (Javascript, AHK, Selenium, etc.)?
|
|
|
|
|
|
I am using c#.
I want to print bill of a shop which contains dynamic data.
currently i am converting it in pdf,saved it in a folder & then print it.
what i have to do so that i can directly prepare a bill format using c# and print it without saving & converting it into pdf.
I think i can use datagridview.
Is there any better option rather than using datagridview.
|
|
|
|
|
Look at using the PrintDocument class[^] - the link includes an example.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|