|
Hi,
what Abhijit Jana told you is correct.
Steve1_rm wrote: The DownloadDataAysnc does show progress.
No. What the MSDN page says is "(This event) occurs when an asynchronous download operation successfully transfers some or all of the data." So it tells you some progress has been made, it does however run on some thread (most probably a ThreadPool thread) different from the main thread, and hence it is not allowed to touch any Control.
You may want to read some of my articles:
- http://www.perceler.com/articles1.php?art=asyncpool1[^]
- http://www.perceler.com/articles1.php?art=crossthreads1[^]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I've got a few comments on the code although it does look essentially correct and I can't see anything that is obviously broken.
1) In the completion handler there is no check for success and without that it is not possible to draw any conclusions about other parts of the operation.
2) In the example given the results string is very short, only 6 characters, and so it is quite possible that the first progress notification is 100%. Log the e.BytesReceived and e.TotalBytesToReceive values to get a bit more info here.
3) Bear in mind that UpdateAvailable will return before the download is complete as DownloadDataAsync is non blocking. This leaves the WebClient object eligible for garbage collection and that could cause problems.
Example code for checking successful completion:
private void DownloadDataCallback (Object sender, DownloadDataCompletedEventArgs e)
{
if (e.Error == null && !e.Cancelled)
{
byte[] data = e.Result;
}
else
{
}
}
I've read the other responses and it has been suggested that you should not update the progress bar directly due to cross thread issues. I disagree as WebClient operates in the same way as BackgroundWorker with event notifications marshaled to the UI thread. This means your code is safe without using Invoke on the controls.
Alan.
|
|
|
|
|
Hello,
I have an application made in visual C# which is largely dependant on communicating with an online MS Access database (hosted on jabry.com). It will have several users who are going to update the information on the database, so having it locally is not an option. I have tested it locally, and it works without any problems. I have no idea how to write the connection string for when it is ONLINE though. I've tried a lot of stuff... but nothing is working.
Any help would be greatly appreciated!
|
|
|
|
|
Define "online"?
If you're talking about user who have to get to the Access database over the Internet, then you've picked the wrong database engine entirely.
|
|
|
|
|
I use sql server but i think it works quite the same
"It will have several users who are going to update the information on the database"
remember to manage threads in your applications if you didn´t do that yet
"I have no idea how to write the connection string"
download microsoft absolute beginners lesson videos (it´s free), there you will find out how to connect to a databade from a asp site
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Does the server allow remote connections? I seriously doubt it - databases that are provided by an online webhost are usually not available for connection from your local machine.
Same goes for MySQL en SQL Server. They're usually not open to "the internet", and as such, you cannot use such a database as a shared repository. You can use them in a webapplication, once it is installed there (local!)
I are Troll
|
|
|
|
|
Greetings to everyone ... I have a question Can < I write programs in C # to Micro Controllers, as in the C language >
< Are there any functions to control the language or are of limited use >
|
|
|
|
|
Not that I'm aware of. Depending on the µC you're using, your possible chices will probably be C, some variation of BASIC, or assembly.
Personally, I do all my stuff in assembly with µCs, I've never felt the need to use a higher level language with them.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank you very much .( DaveyM69) .. But something did not take advantage
1-Can < I write programs in C # to Micro Controllers, as in the C language ???>
2-< Are there any functions to control the language or are of limited use ??? >
|
|
|
|
|
Nasir13 wrote: Can < I write programs in C # to Micro Controllers, as in the C language ???>
Allow me to repeat the same stuff for DaveryM69. NO - you cannot write anything for microcontrollers in C#. C# requires that the .NET Framework be installed on a machine running the code. Since your microcontroller isn't running Windows, this is impossible.
Nasir13 wrote: 2-< Are there any functions to control the language or are of limited use ??? >
The question makes no sense. I have no idea what you're trying to say.
|
|
|
|
|
No, none exist (that I know of).
You could possibly write a wrapper around the microcontroller's opcodes, and write code to generate Hex files from that - effectively a C# to uCxxx compiler, but that is going to be a pretty big task.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Totally agree with Davey here. I generally use c/c++ for even embedded processors, let alone micro-controllers.
|
|
|
|
|
Greetings and thank you .. Answer like a fire escape
I am a new user to the language of C #, I used VB to control
May be most programmers in C # to develop the site or building applications
But the question of experience in Imktlk Pic
Can I write programs and transfer the file to Hex in C # ????
|
|
|
|
|
Greetings and thank you .. Answer like a fire escape
I am a new user to the language of C #, I used VB to control
May be most programmers in C # to develop the site or building applications
But the question of experience in Pic
Can I write programs and transfer the file to Hex in C # ????
|
|
|
|
|
There is no compiler for C# to pic or any other microcontroller. It is very unlikely that there would ever be one, nor would I want to use it if there were. C# is heavily heap based; garbage collection is a necessity and would increase in frequency with the reduced memory associated with microcontrollers. If you want a garbage collected memory system in a real-time environment, then you need to think quite carefully about the implications: What happens when you need a variable under interrupt and the garbage collection is required?
I would normally use Assembler, C or C++ but with caution: I never use malloc/free or new/delete in an embedded system because I would expect the unit to run 24 hours a day, 365 days a year. Since malloc/free and new/delete can fragment the heap and cause failure I allocate memory either statically or once only and then re-use. This is not feasible in C#.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Sorry, I'll have to disagree with most of the above.
I will admit that I am fairly new to C# and .NET!
But, I've been doing embedded systems and coding for over 20 years. I still remember using punched cards, paper tape, teletype terminals, etc.
Right now, as far as I know, there isn't C# compiler that will allow someone to do their embedded OS from scratch.
But, C# isn't magic. In fact, *I* would say that it's light years beyond the horrible job that was done with the C++ spec. IMHO, C++, represents just about everything that could be wrong with a language!
BTW: I've done YACC and other custom compilers/assemblers for micros/minis. Remember, back in the old days, that's often how things were done.
As for the "garbage collection" for C++, that's what gets into a gray area for micros. IMHO, there is no such thing as a "standard" C/C++ compiler. Yea, there's the BS standard. So what? It's vague in areas, and unless you do sizeof for everything, your code will break. Even then, compiler support differs.
So, the point is that for C# (or any other language), there's always "wiggle room" when it comes to how a company will do a compiler for an embedded micro. It would not be "unreasonable" if a compiler company added some other requirements or restrictions in the coding due to the C# intended use of garbage collection. For example, a compiler company may require an explicit call to the GC, and/or additional constructor/destructor coding.
Microsoft made Visual Studio C# output platform and processor independent. So, as long as you have enough memory, in theory, you can run your VS programs on any platform. Again, we get into the "embedded vs Windows" world of things. So, not all of the Windows calls makes sense in an embedded app.
IMHO, it will be hard for any language to compare to C for embedded apps. Sorry, IMHO, C makes far more sense in many way verses assembler. Or, IMHO, any other language. For one thing, C can be coded much faster and is far easier to understand. Also, C can be optimized. People suck at optimizing code. Now, it's very rare that a company has the time or desire to spend time on greatly optimizing code. Heck, I'd say that in 99.9999% of the code that is used by people, from the company's point of view, added features were far more important than speed or stability fixes. So, getting code done quickly often takes much higher priority than speed or compactness.
As for .NET in embedded applications, it's being done. I think a few people on here are involved in .NET on embedded systems.
http://www.embedded.com/news/embeddedindustry/197005919?_requestid=208524[^]
http://blogs.msdn.com/mikehall/archive/2007/02/05/net-microframework-and-windows-ce-what-s-the-difference.aspx[^]
As for me, I'll stick to C for my embedded systems, and I'll use C# for my Windows apps. IMHO, those are the best for each application.
modified on Saturday, August 1, 2009 10:47 PM
|
|
|
|
|
Like you, I grew up with cards and tapes (and am soooo glad those days are over).
I have to disagree with you a bit though:
mustang86 wrote: People suck at optimizing code
Not always. Because the coder knows what hardware result they are trying to achieve (a square wave clock with data as applicable for example) they can often be considerably more efficient than a C compiler which can only optimize the higher level instructions, without regard for the algroithm. A mix of C and assembler is the best way IMHO, with assembler kept for when it is realy needed.
Embedded C++ can be a better choice than straight C, particularly if a project is going to get complex.
mustang86 wrote: So, getting code done quickly often takes much higher priority than speed or compactne
Depends on the company priorities: if you are going to ship hundreds of units, then yes. If you are going to ship hundreds of thousands of units, then hardware cost becomes the priority and the software has to work round it's limitations. Saving peanuts on hardware adds up fast when you ship enough!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi im using VS2008 / SQLServer2005
Im using Linq, ive created my .dbml file - is there a tool in vs2008 that I can use to generate the DAL and/or BLL for basic CRUD operations or do I need to code it myself?
Many thanks,
Chas
|
|
|
|
|
Yes and no. You can use the T4-enigne[^] in VS2k8 to generate the source-code, but then you'd probably have to write the templates yourself.
You can also research MyGeneration [^]or CodeSmith[^].
Good luck
I are Troll
|
|
|
|
|
|
Sorry to have to post this guys and I believe this is the right group to target. Any help would be absolutely fantastic and obviously very much appreciated.....
I would say I am a beginner and have learnt from asp.net c sharp and SQL books. I have got to a stage where things make sense and like many of you will know it is pretty good place to be. Obviously I still have a long way to go hence I have thrown myself into a project which will I guess test many core technology.
Basically I am going to start work on a business system which logs information at each stage of a production process. The item gets picked up and ideally scanned in as it should already have a barcode (act as a primary id). When it gets to the premises it is booked in and then goes through each process of modification or testing (refurbishment) and then sent out again to a new origin when it is sold.
Ideally I want to use ASP.NET, C sharp and obviously SQL. Could you guys possibly give me some advice as to what areas of additional technology I should look into to implement it if there is anything? I trust barcode readers are universal and just plug the serial onto an excel spreadsheet which I could import into SQL database.
I read about things like Workflows, MVC's LINQ an WPF etc etc or is this not the way forward. I have a logical idea of how this thing should work but unclear as to what is out there if you see where I'm coming from.
I like the idea of running Sharepoint alongside this system but that comes later.
Any help will be awesome. Where to start? Just hope I haven't screwed myself!
Cheers for reading everyone.
|
|
|
|
|
I am using a datagridview with an INSERT, DELETE and an UPDATE button. But whenever I run my form the error that I have stated above rises. Kindly help me to solve this problem.
<code>
string constr = "Server=PACE-BB95D506B2; Database=Dotnet67; uid=sa; pwd=123";
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
DataTable table = null;
SqlDataAdapter da = null;
private void LoadCashiers()
{
string query = "SELECT * FROM Cashier_2";
da = new SqlDataAdapter(query, constr);
table = new DataTable();
da.Fill(table);
dataGridView1.DataSource = table;
dataGridView1.Refresh();
SqlCommandBuilder b = new SqlCommandBuilder(da);
// The error rises in the line of code below
da.UpdateCommand = b.GetUpdateCommand();
}
private void ManageCashier_Load(object sender, EventArgs e)
{
LoadCashiers();
}
private void btnLoadCashiers_Click(object sender, EventArgs e)
{
LoadCashiers();
}
private void btnInsertCashier_Click(object sender, EventArgs e)
{
DALHelper helper = new DALHelper();
helper.InsertCashier(textBox1.Text);
LoadCashiers();
}
List<int>cashierIDsToDelete = new List<int>();
private void btnDelete_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
bool deleteStatus = Convert.ToBoolean(row.Cells[0].Value);
int cashierID = Convert.ToInt32(row.Cells[1].Value);
if (deleteStatus)
{
row.Selected = true;
cashierIDsToDelete.Add(cashierID);
}
}
foreach (DataGridViewRow selectedRow in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(selectedRow);
}
DALHelper dal = new DALHelper();
dal.DeleteCashiers(cashierIDsToDelete);
cashierIDsToDelete.Clear();
// Load Cashiers from Database
LoadCashiers();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
da.Update(table);
MessageBox.Show("Update");
}
}
</code>
|
|
|
|
|
The error means you don't have a primary key defined in your database table.
A primary key is mandatory if you want to use SqlCommandBuilder .
You must either define a primary key in the database table or write the code to build the insert, delete and update SQL commands by hand.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
i have developed a very simple application which contains a single win form and two classes.
i would like provide or show some text from those classess into my win textbox form.
how can i achieve it?
what I want excatly sames as "View Syn status" in MY SQL Replication.
i am trying to achieve from c#.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Use
string s = "Hello";
textBox.Text = s; for a single line TextBox, or
string[] as = new string[n];
...
TextBox.Lines = as; for a multiline.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|