|
-hi there guyz, does anyone knows about PC/SC using C# 'cause im having hard
time in coding it specially in SCard Get ATR and SCard Transmit.. any idea?! tnx for helping me..
|
|
|
|
|
I'd like to write a metronome application in C#.
What Timer class would you recommend for accurate time-keeping.
I also plan on using DirectSound to play the WAV files representing the ticks. Does this impose a significant overhead?
If you know of code for a metronome app in C#, I'd appreciate it. This would only be for personal reference. I will not copy the code and use it in my app.
|
|
|
|
|
NietzscheDisciple wrote:
What Timer class would you recommend for accurate time-keeping.
Just the normal one will be fine.
NietzscheDisciple wrote:
I also plan on using DirectSound to play the WAV files representing the ticks. Does this impose a significant overhead?
What on earth for ? Why rely on Direct Sound to play a simple sound file - it's overkill. And DirectSound is used in games that are doing a lot more than firing a timer, I doubt it will bring your app to it's knees if you use it
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks for the reply, Christian.
I've done some DirectSound programming and it's pretty neat. My apprehension was that the SecondaryBuffer wouldn't clear "cleanly enough" for this application. Esp. if the metronome was going at 180 bpm+.
|
|
|
|
|
|
hey - does anyone know where I can find a class library (ideally in C# but any .Net classes will do) which allow me to edit tags on MP3s and Oggs. I need ID3.v2 support for the mp3 tags.
Thanks in advance!
|
|
|
|
|
When I needed id3v2 support, pretty much the first hit google gave me got it. ogg is another matter.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi,
I have a listbox with three values on it and a button on my form. When I pressed the button the listbox have to select the next item after 2 seconds. Then select the next one after 2 seconds... And so on... Here is my unworking below code:
Anyhelp would be greatly appreciated...
Thank you indeed...
Cem Louis
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Timers;<br />
using System.Threading;<br />
<br />
namespace WindowsApplication14<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.ListBox listBox1;<br />
private System.Windows.Forms.Button button1;<br />
private System.Timers.Timer timerClock = new System.Timers.Timer();<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
public void InitializeTimer()<br />
{<br />
this.timerClock.Elapsed += new ElapsedEventHandler(OnTimer);<br />
this.timerClock.Interval = 2000;<br />
this.timerClock.Enabled = true;<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.listBox1 = new System.Windows.Forms.ListBox();<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.listBox1.Location = new System.Drawing.Point(8, 8);<br />
this.listBox1.Name = "listBox1";<br />
this.listBox1.Size = new System.Drawing.Size(120, 95);<br />
this.listBox1.TabIndex = 0;<br />
this.button1.Location = new System.Drawing.Point(8, 112);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(120, 23);<br />
this.button1.TabIndex = 1;<br />
this.button1.Text = "Run";<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(136, 142);<br />
this.Controls.Add(this.button1);<br />
this.Controls.Add(this.listBox1);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
listBox1.Items.Add("Arthur");<br />
listBox1.Items.Add("Alex");<br />
listBox1.Items.Add("Amie");<br />
listBox1.Update();<br />
}<br />
<br />
private void OnTimer(object source, ElapsedEventArgs e)<br />
{<br />
this.nextvalue();<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.nextvalue();<br />
}<br />
<br />
private void nextvalue()<br />
{<br />
for(int i = 0;i<listBox1.Items.Count;i++)<br />
{<br />
listBox1.SetSelected(listBox1.Items.Count-i,true);<br />
}<br />
|
|
|
|
|
I am no guru, but it looks like the problem may be in nextvalue(). Perhaps it was a cut & paste error, but the "for" statement is incomplete. The other problem could be the statement "listBox1.Items.Count-i"; if i is 0, the command would error because the count is always 1 larger than the indexing. How I would attempt to rotate through the items would be:
int i = listBox1.SelectedIndex + 1;
if ( i == listBox1.Items.Count ) i = 0;
listBox1.SetSelected( i, true );
Hope this helps!
|
|
|
|
|
Hi Smith,
Not working
|
|
|
|
|
Two things:
1) Make sure the nextvalue() has the code I included earlier:
private void nextvalue()
{
int i = listBox1.SelectedIndex + 1;
if ( i == listBox1.Items.Count ) i = 0;
listBox1.SetSelected( i, true );
}
2) The timer event that is being used could be incorrect. When I add a timer to my test project, then click on the Events button (the "lightning bolt") in the Properties grid, the only event displayed is the Tick event. Double-click on the Tick title and it will auto-magically add the event to the code. Put the "nextvalue()" call in that subroutine, then try running it.
Hope this helps!
|
|
|
|
|
Have you been able to get the timer working? I apologize for overlooking the possibility that you were probably trying to learn about handlers, more so than getting the timer to work.
As fate would have it, I have had to work with timers and handlers in the past week. So, I took another look at the original code posted. I made three changes and was able to get the program to work:
1) Modify nextvalue()
private void nextValue()<br />
{<br />
int i = listBox1.SelectedIndex + 1;<br />
if ( i == listBox1.Items.Count ) i = 0;<br />
listBox1.SetSelected( i, true );<br />
}
2) Add a call to InitializeTimer() in the form constructor:
This is a public method, so another program could have been calling it. But since I cannot tell, I added a call in the form constructor:
InitializeTimer();
3) Modify the handler definition and code:
The definition of the handler is still in InitializeTimer(). I was only able to find a handler for "Tick", not "Elapsed".
this.timerClock.Tick += new EventHandler(timerClock_Tick);
The neat thing about adding the handler is that Visual Studio will do most of the work for you. After typing "+=" you will be prompted to "Press TAB to insert" the remaining of the command. You will immediately be prompted a second time to "Press TAB to generate handler". After generating the handler, add the call to nextvalue() within that event handler.
private void timerClock_Tick(object sender, EventArgs e)<br />
{<br />
nextValue();<br />
}
Hope this helps!
|
|
|
|
|
I have a process that can take over ten minutes to complete. So, I added an update dialog box with an axAnimation (axMSComCtl2) control. I update a label as the little wheels spin in the AVI. Works great (using an explicit path in the Open method)! Here's the current code that works:
string sAppPath = Path.GetDirectoryName(Application.ExecutablePath);
string sAviFile = sAppPath + "\\PleaseWait.avi";
axPleaseWait.Open( sAviFile );
axPleaseWait.Play(0, 0, 0);
The problem is the file distribution. I have been asked by the powers that be to embed the AVI file in the project. I have found two ways to embed an AVI file: 1) right-click on the project, select "Add existing item", then browse to and select the AVI file (found by trial & error); 2) create a resource file, add the AVI, and then add the .resource file to the project (found in the MSDN). But I have yet to figure out how to get either of these methods to work!
The problem with the first method is that I have no way to get a path to the AVI file listed in the Solution Explorer. I thought about writing it to a temp file, but I have not figured out how to read in the AVI file. (I think this would be the most straight foward method to use).
The problem with the second method is that the resource file will not let me explicitly state that this is an AVI file. So, I selected Bitmap. I don't even know if the AVI has been added to the .resource correctly. Likewise, I have not figured out how to get the AVI file back out of the .resource file.
Any help would be greatly appreciated. Thanks!
|
|
|
|
|
I am trying to get the CPU usage percent of a given process (in this example, iTunes). This example always prints "iTunes is using 0.0000% CPU":
Console.Out.WriteLine("iTunes is using {0:0.0000%} CPU",
new PerformanceCounter("Process", "% Processor Time", "iTunes").NextValue());
What am I doing wrong? The Performance program under Administrative Tools in Windows XP correctly displays the CPU usage of iTunes using these exact arguments to the constructor of PerformanceCounter. In a different section of code, using _Total as the instance name properly retrieves the total CPU usage of the system.
(the emoticons are quote followed by P that got parsed by this forum)
|
|
|
|
|
|
The % was just a typo in the post.
Every now and then, the CPU usage will also be reported as 100%.
|
|
|
|
|
Hi every one,
I am new in .NET and this is my first time entering the message board. You might find my questions are pretty dummy. OK, here is my first question:
Why the tab control in .NET Campact Framwork looks upside down? How can I change it.
Thank in advance for your help,
Willa Wei
BTW, if you find I am at a wrong place, please tell me where I can ask question like that. Thanks.
|
|
|
|
|
Willa Wei wrote:
Why the tab control in .NET Campact Framwork looks upside down? How can I change it.
It's 'upside down' because that's how the handheld UI works, just like the start button is at the top instead of the bottom. It's NEVER a good idea to deviate from UI standards that users are accustomed to without VERY good reasons.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I am attempting to write a code sample where I define a toolbar complete with images. I then would like to click on the particular toolbar button, which would move that toolbar icon button's image to main form. ( which I have working) The problem comes when I want bring a second copy of the item down to the main form.
I believe the form.refresh() is deleting the orginal bitimage. how do i save images on the mainform.
DanTubby
|
|
|
|
|
Dantubby wrote:
I believe the form.refresh() is deleting the orginal bitimage. how do i save images on the mainform.
Do you have a picture box on your form or are you using the Graphics class to draw the image to the form? What do you want the images to do when you already have one image there? Can you clairfy some of this first?
- Nick Parker My Blog | My Articles
|
|
|
|
|
I am using a graphics class to draw images to the form. I am attempting to build a network simulator with the basic functionality of the NAM portion of NS2. So the toolbar buttons represent nodes, and links currently. I would like to be able to interactively place the nodes and links on the form and connect them.;)
Dan Smith
|
|
|
|
|
How to use soap for long time server treatments (more 1 hour)?
How to use soap for significant data exchanges (more 100 Mo)?
i use wse functions : SoapEnvelope, SoapClient, SoapService and protocol http but when the server treatments is too long (more 2 minutes) i have this error message.
Subscribing...
Unhandled Exception: System.Exception: Operation Timed Out
at Microsoft.Web.Services2.Messaging.SoapClient.SendRequestResponse(String me
thodname, SoapEnvelope envelope)
at messaging.PublisherClient.recherche(SoapEnvelope env) in c:\inetpub\wwwroo
t\subscriber\subscriberapp.cs:line 60
at messaging.rechercherApp.Main(String[] args) in c:\inetpub\wwwroot\subscrib
er\subscriberapp.cs:line 19
i try to change server and client web.config (executionTimeout=-1,maxRequestLength=-1) and machine.config (httpRuntime executionTimeout=3600 maxRequestLength=4096) but no result.
jf
|
|
|
|
|
What does your problem have to do with Web Service Enhancements (WSE), as you implied in your post? This problem would exist for just simple HTTP GET requests. Timeouts are inevitable with HTTP and many other protocols.
Waiting for long operations over HTTP is not recommended. Both servers and clients will timeout eventually, even when on local area networks (LANs). If you need to run a long operation on a server triggered by a client, then you should use something like WS-Addressing in the WSE 2.0.
Basically, your client needs to poll the server (or a server, if your routing messages around) with a request for completion. The server either tells the client "no, I'm not done yet" or "I'm done, here's your data". The client should have the ability to tell the server "stop, I don't care anymore". Trying to extend the timeout to enough time is not a good idea, either, since genuine errors would take that much time before an error is reported back to you.
Finally, never change the machine.config file when you can make changes closer to the client (like the web application's Web.config, the site's Web.config (in /), or YourAppName.exe.config)! Clients don't even use the <httpRuntime> section; it's used only by ASP.NET.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for your answer.
Do you think it's possible to use tcp/ip protocol with wse to resolve my problem of timeout
jf
|
|
|
|
|
You already are. HTTP - the Hypertext Transfer Protocol - runs on to of TCP/IP - the Transmission Control Protocol/Internet Protocol. Almost every protocol that runs across the internet rides on TCP/IP (a few use UDP, but rarely).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|