|
Hi,
Steve1_rm wrote: The problem I have is that the buffer will overrun
Are you sure about that? It looks to me as if you are attempting to read beyond the end of the array.
Every iteration of the while loop reads data into the samples array. That's ok but eventually the indexer i has the value 4096 and the array access in the line audioValue = Math.Abs(samples[i++]); will fail.
I can't understand the meaning of audioValue and how it would relate to progress. Did you mean to report total amount of data read perhaps?
Alan.
|
|
|
|
|
Steve1_rm wrote: It there anyway to create a circuler buffer that once it gets to the the end it will start over again?
Sure, just index with i%length or i&(length-1) for powers of 2 (which you have here)
|
|
|
|
|
So i've slowly been learning c# over few months but going slow and is my first language.
One thing i would like to know, is how it would get a c# program to take data from a website then display inside the application. (Not taking data from a database)
Could anyone possible point be at examples or tell me roughly what i would have to do.
Thanks in advance,
Malcom
|
|
|
|
|
Hi,
there are a couple of ways to do that:
1.
add a WebBrowser to your form, make it navigate to your URL, then grab its DocumentText.
You could do that with a hidden WebBrowser as well.
2.
use HttpRequest and HttpResponse classes to access the web yourself.
This is faster, but a bit more complex.
FWIW: make sure to study a good book[^] on C#
|
|
|
|
|
Yeah i have heard of HttpRequest and Response. I didn't want to use a browser.
So on return of the data it is possible to display it differently. For example come up in a textbox or different controls im not really thinking of just now.
Thanks for the book recommendation, i'm looking for the best one at Amazon
|
|
|
|
|
the response is always a string, it is a text following HTML conventions.
|
|
|
|
|
Thanks for the help
|
|
|
|
|
You're welcome.
|
|
|
|
|
You can use ADO.NET to create database for the website, and then connect to it with the C# application.
or you can do someting that call "web service" - open new ASP.NET Web service in your Visual Stduio, there, you can define methods that after you can call to then with your C#.
after you finish define, go to the C# project, and then on the solution explorer->referance of the project click left mouse, click "Web referance", and look for your web service address, then you can use all the methods you defined.
Gindi Bar Yahav - Web & Software developer.
|
|
|
|
|
Hey my friends ...... I have a password text box(i.e PasswordCharacter='*') there is one check box which allows the user to see its password or just the star ....... I tried to change the value of the text boxes passwordCharacter(i.e txtbox1.PasswordCharacter='') but it says "it is not allowed to make empty" ... so how can I do that??
Thank you
|
|
|
|
|
matiIsGreat wrote: I tried to change the value of the text boxes passwordCharacter(i.e txtbox1.PasswordCharacter='') but it says "it is not allowed to make empty"
No, you can't have an empty character literal - unlike a string which has a variable length 0..n and thus can be empty, a character has a fixed size (16 bits). Use '\0' for a null character and it will do what you want. Or, use "UseSystemPasswordChar" instead of "PasswordChar".
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
|
|
|
|
|
I read an article on Msdn about how to restrict users from setting focus to a specific cell in DataGridView , and I understood how it work , but what really I need to now is how to restrict users form set focus to a multiple cells and especially if two cells are exactly adjacent
for example if I have 4 columns in a DataGridView and and the columns to skip are 2nd and 3rd , so how can i do that
|
|
|
|
|
Take a look at How to: Make Columns Read-Only[^] on MSDN.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hi Developers..
I need to print a text and images without using printer driver.
using c#.net
i really need it done any how..
thanking you
|
|
|
|
|
I hope you know exactly the commands you need to send to the printer to do what you want. You can bypass the printing system. There's an example in this KB article[^].
|
|
|
|
|
Dear Dave,
Thanks for your replay
I have already gone through the link you have given ..
actually I need to print image at the top, text and image at the bottom.
I dont know exact commands which i nee to send printer to print image and text
Thanking you,
|
|
|
|
|
Those ARE the commands you use to send the data. You need the know WHAT you're sending to the printer. What do you have to send to the printer to tell it how to render the text and image you want. This is NOT going to be done for you and the commands will be different for every printer. This stuff will be documented in the manual for the printer. If you don't have it, contact the manufacturer of the printer to get one. Without it, you have no hope of doing what you want.
|
|
|
|
|
Dear All, I have following code to run 10 thread at same time
for(byte i=0; i<10; i++)
{
Thread t=new Thread(new ThreadStart(runAction));
t.IsBackground=true;
}
void runAction()
{
if (InvokeRequired)
{
BeginInvoke(new run(runAction));
return;
}
}
If i uncomment the code Application.DoEvent() then it will give me the responsive interface, but also it starts the last action first, while i want to run them concurrnetly and then the second last and so on to first.
if i comment the code Application.DoEvent() then only one (first thread) runs and others are stack, like one finish then another start and so on.
I want to run thread concurrently and i would like have my UI working?
what is wrong with my code?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
You're not showing enough of the code. What is "run"? Is this code sitting on a form or in a seperate class?
Also, did you know that every thread you launch costs you 1MB of RAM and is an expensive operation? Is there any particular reason for doing this??
After all that, you're not launching the same operation on 10 seperate threads. Each of your threads is calling the same function ON THE UI THREAD. So it's not suprising that your UI is frozen during this time. All you did was launch the call on a background thread, which farmed out the work of "runAction" back to the UI thread.
You do the work in the background threads and then if they have any updates to the UI that need to be done, they can Invoke a method that does the update on the UI thread.
|
|
|
|
|
Well, this is real code.
foreach(ListViewItem prv in des.lProvinces.CheckedItems)
{
if (prv.Text.Equals("All"))
continue;
pmuAccessPath=string.Format("{0}\\{1}\\NSPDatabase.mdb",des.DestinationFolder,prv.Text.Trim());
if (Directory.Exists(Path.GetDirectoryName(pmuAccessPath)))
Directory.Delete(Path.GetDirectoryName(pmuAccessPath),true);
Directory.CreateDirectory(Path.GetDirectoryName(pmuAccessPath));
if (!File.Exists(pmuAccessPath))
File.Copy(des.SourceAccessPath,pmuAccessPath);
Triplet triplet=new Triplet(prv.Text,pmuAccessPath,prv.Tag);
Thread t=new Thread(new ParameterizedThreadStart(runMultiple));
t.IsBackground=true;
t.Start((object)triplet);
}
delegate void run(object var);
void runMultiple(object varr)
{
if (InvokeRequired)
{
BeginInvoke(new run(runMultiple),varr);
return;
}
Triplet variables=varr as Triplet;
string prv=variables.First.ToString();
Finish fin=new Finish();
pnlControls.Controls.Add(fin);
fin.Dock=DockStyle.Top;
fin.lblProvince.Text=string.Format("Province : ({0})",prv);
fin.lblProvince.Refresh();
string query=string.Empty;
byte tableCount=43;
string pmuAccessPath=variables.Second.ToString();
int prvId=Convert.ToInt16(variables.Third.ToString());
}
based on my idea, all thread should run at same time, but in this case it doesent.as i told n msg that if i remove the code "Application.DoEvent()" the interface is totaly stack, but if i use that code then every thing is responsive, while my last action is done first and then it continues.
but bothering is that only one thread runs at atime, i can see running threads in progress bar.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
how to connect 9 pin serial port plug to itself so tha one can recive the data in the 2nd Pin andtransmit in 3rd pin.
I am not able to send or recive the data throuth 9 pin plug serial port.
|
|
|
|
|
Connect pin 2 to pin 3, and unless there is some hardware handshaking, it should work. If handshaking is used, then connect 7 to 8, then 6 to 1 and 4 if required. See here for pinout[^]
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
|
|
|
|
|
I tried i am only able to recive but i am not able to write serial port.i mean i am not able tosend the data.Below is the code snip.
if (serialPort1.IsOpen == false)
{
this.serialPort1.Open();
}
this.serialPort1.Write("3F 50 52 40");
|
|
|
|
|
A couple of things:
1) Are you aware that
serialPort1.Write("3F 50 52 40"); will write 11 bytes, not 4?
2) Are you sure that you wired the connector the right way? The pin numbering is normally molded into the connector with a "1" beside pin one. If you are recieving ok, then you are presumably connected to something else as well, which would imply you have wired the connector wrong for loopback.
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,
if you need to test some serial port software, you can do so without requiring actual serial port hardware, by using virtual ports. Here[^] is an example for you; I used the com0com virtual driver successfully, it brings you a pair of virtual serial ports that seem connected by a null modem cable.
|
|
|
|