|
Don't post the same thing in multiple forums. Pick the right forum and stick to it.
also "urgent" will work against you.
|
|
|
|
|
sorry for that Luc. Actually I was frustrated with the problem I have so...
|
|
|
|
|
I am trying to create a program to copy a large amount of files from 1 hard drive to another. I do not need network copy capabilities. I was trying to figure out which program will transfer files faster. I am not an expert at programming, but I am capable of creating a program in either language. If anyone know of a better language for this purpose, I am open to suggestions. Thanks for any help anyone can give me.
|
|
|
|
|
Since they are both .net languages speed isn't an issue, they will each produce the same il (or should). If speed is what you want then you'll need to use unmanaged C++.
only two letters away from being an asset
|
|
|
|
|
I can't update the content of the field called "VALUE". Is there any work around to get "1" into that field?
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\;Extended Properties=dBASE IV;")
Dim adapter As New OleDb.OleDbDataAdapter("SELECT * FROM Test.dbf", conn)
Dim recordsAffected As Integer = 0
conn.Open()
Dim sql As String = "UPDATE Test.dbf SET Value = '1' WHERE Keyword = 'Over_here'"
Dim da As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql, conn)
recordsAffected = da.ExecuteNonQuery()
conn.Close()
|
|
|
|
|
'value' is a keyword in t-sql which is what the problem probably is. You could wrap the word in square brackets '[value]' which might solve the problem - I haven't got time to try it right at the moment though...
It definitely isn't definatley
|
|
|
|
|
|
In my application (VBexpress 2005), I would like to have a process read data from an incoming stream and process it. A blocking read would be fine except that I would like the user to be able to switch between serial ports and TCP connections. It would not be acceptable to simply leave the unused connections open--system requirements dictate that they actually be closed.
Which of the following approaches would be best:
- Use a blocking read with a timeout, and figure out some method to get rid of all the 'first chance exception' messages for the timeouts (can anyone tell me how to do that without having to globally disable all first-chance messages)? This would involve some waste of CPU time, but if I use a one-second timeout it wouldn't be too bad; delaying the release of the resource by a second would not be objectionable.
- Use a blocking read, and then use .Interrupt on the thread if the port needs to be closed. I'm not sure whether that's guaranteed to work without problems, however.
- Use a blocking read, and then rudely close the port in another thread. I think that would probably "usually" cause the read to immediately return a failure, but I don't know that such behavior would be guaranteed.
- Use a non-blocking read and close the port while it's pending. I'm not sure whether that would be "safe" either.
- Somehow do a read which will wait up to an indicated amount of time (without busy-waiting), but--if no data arrives--will simply return no data rather than throwing an exception. I think I can do this with the TCP ports, but don't see how to do it with serial ports other than busy-waiting.
- Something else?
If there were a documented way of telling the system to abandon an asynchronous read operation, that would probably be the ideal method. Unfortunately, I know of no way to do that. I don't want to simply experiment and go with whatever works, because--other than the timeout method--all the approaches rely upon partial thread safety of operations which are not specified as thread-safe. The timeout method is in some ways a little icky, but I'd actually prefer to go with that for simplicity if I could get rid of the annoying "First chance exception" messages. Is there any nice way to do that?
modified on Thursday, January 8, 2009 2:55 PM
|
|
|
|
|
You'll pretty much have to read with timeout. The blocking reads will block in unmanaged code... which prevents things like thread.abort.
I normally have "break on thrown" on, and then disable that for all the exceptions that I can't work around. Current app I'm working on is a very large SCADA app - and the only "expected" exceptions come from an SVG library that doesn't have a "TryGetElement" :S
|
|
|
|
|
You'll pretty much have to read with timeout.
What sort of brilliant designer doesn't allow a 'wait and see if any data comes in, but recognize that a lack of data is also a normal condition' operation? Probably the same one who designed .net 1.0 without things like Date.TryParse I guess.
I wish there were some sensible way of enabling the diagnostic messages for exceptions in some cases but not all. In some of my applications there are exceptions which will be somewhat expected though they shouldn't be terribly frequent. In such cases, I sometimes just swallow them (assuming they're of the right type) but the "First chance exception" diagnostics can alert me if they're happening much more often than they should. Is it possible to hook in some sort of event handler for a first-chance exception that could log exceptions that seem suitable (using a thread-safe logging system, of course)?
|
|
|
|
|
supercat9 wrote: Probably the same one who designed .net 1.0 without things like Date.TryParse I guess.
Okay - I feel that is an unfair comment. I attended a talk last year at Microsoft and what was interesting was that they were saying that there were aspects to C# and the .NET framework that have been on the drawing board since before V1 was released that are only just going into V4.
Now, think about this from a business perspective. Do you wait until you have an absolutely perfect product before going to market, or do you go to market earlier with a product that will satisfy most people? If you answer the former then you won't last very long in business because you'd burn through your Venture Capital way before you released anything to the market and your competitors would have stollen all your potential customers.
Seriously, ignorant comments like that really piss me off. Yes, the .NET Framework may have its faults but are you seriously telling me that you've never had to cut features or use a workaround because of business and time-to-market pressures?
|
|
|
|
|
I did finally figure out a way to make the serial port work reasonably, using a received-data event to hit a ManualResetEvent (if the main communication thread has set it). The code creates a new ManualResetEvent every time the main thread polls and there isn't any data available; a monitor might be better, but using the ManaulResetEvent makes it possible for another thread to set a 'hurry up and abort the current operation' WaitHandle (which could be used, along with the former, in a WaitAny).
Okay - I feel that is an unfair comment.
Since there seems to be a good solution using events, I'd agree that my apparent antipathy toward the authors of the SerialPort class was somewhat misplaced. The Windows communications API has somewhat dubious semantics (which probably go back aeons) and the SerialPort class is mostly just exposing them. The decision to have a timeout error always throw an exception is unfortunate, but the availability of the receive data event makes it possible to emulate the two styles of semantics that a good communications library should support:
-1- Wait up to a specified time for 'n' bytes; if fewer than 'n' bytes become available in time, do not return a smaller number, but instead flag an error (or throw an exception).
-2- If any data is available, return it. Otherwise, wait up to a specified amount of time (possibly zero) to see if any arrives.
The Windows API is a mishmosh of these approaches, so I suppose it makes sense that the SerialPort class would be as well.
Colin Angus Mackay wrote: Do you wait until you have an absolutely perfect product before going to market, or do you go to market earlier with a product that will satisfy most people?
Maybe I was a bit too sarcastic, but to my mind the concept of a 'try' pattern should be a core part of any non-trivial exception-based code, except in circumstances where it's not practical to predict an operation's success without committing to the operation. Whoever made the first-chance exceptions go to the immediate window was clearly trying to encourage programmers to avoid exceptions when practical; a worthy goal, but one which requires giving programmers the tools to do that.
I guess what I find most irksome/puzzling about things like Date.Parse is that I can't imagine that people could use such a function very much without its limitations quickly becoming apparent. If Microsoft had to code around the limitations of something like Date.Parse in order to make its other products work, that would suggest that such workarounds should perhaps have been included in the .net framework in the first place.
Yes, there's a lot more to Windows and .net than meets the eye, but I doubt I'm the only person to stumble upon some of the annoyances.
modified on Thursday, January 8, 2009 10:28 PM
|
|
|
|
|
HI All,
I wrote the following code and i checked with task manager.the result is not correct .Can anyone help me ?
public string Checkcpu()
{ double cpuPercent=0;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name=\"_Total\"");
foreach (ManagementObject objMgmt in searcher.Get())
{
cpuPercent = Convert.ToDouble(objMgmt["PercentProcessorTime"]);
//cpuPercent = objMgmt["_Total"].ToString();//not found
}
//return cpuPercent.ToString();
return _format ? (int)cpuPercent + "%" : cpuPercent.ToString("F") + "%";
}
|
|
|
|
|
S.Rekka wrote: the result is not correct
How so?
Are you calling this at intervals?
This works for me:
for (int i = 0; i < 100; i++)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name='_Total'");
foreach (ManagementObject objMgmt in searcher.Get())
{
Console.WriteLine("PercentProcessorTime: {0}%", objMgmt["PercentProcessorTime"].ToString());
}
Thread.Sleep(100);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yes,i called that function in timer tick.but the wmi result shows on 12% means that task manager shows 34% .I used PerformanceCounter method also it shows on correct. But wmi shows on wrong result.I want to get on wmi only.
|
|
|
|
|
Hiiiiiiiiii all experts........
this is ajay pandey and i m working on a project which requires calling an exe from the init() method.can any body tell me how to implement this and other features of a server which requires processing the data from user b4 it is passed to service method to b served.
Plz suggest me any book if u have in mind as i m a beginer,...........
Thanks
|
|
|
|
|
I think you want to execute an exe in init() mathod?
You can add the namespace System.Diagnostics and can use the Prcess class to execute the exe as
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo("path of you exe");
myprocess.StartInfo = startInfo;
myprocess.Start();
The process would be started and check when this process would be exited then start executing ahead.You can use timer for it.
Cheers!!
Brij
|
|
|
|
|
Hi,
I have a project that is being with SCSF. The project is in first days & we are developing the base classes such as Bussines Entities, ... .
In this process, when I want to run project from Visual Studio, I got Exception with this message :
-------------------------------------------------------------------------------------------------------------------
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Infrastructure.Library.Properties.Resources.resources" was correctly embedded or linked into assembly "Infrastructure.Library" at compile time, or that all the satellite assemblies required are loadable and fully signed.
This exception has occur in the following code:
if (traceSource != null)
traceSource.TraceInformation(Properties.Resources.LogModuleAssemblyLoaded, file.FullName);
-------------------------------------------------------------------------------------------------------------------
This is when until yesterday I could run the project & see output.
Please help me ...... thanks
modified on Thursday, January 8, 2009 4:35 AM
|
|
|
|
|
|
I am developing a mailing application in .Net 2005 (windows). Application requires sending a mail to recipients. The body of the mail can also have emoticons.
For writing the body of the mail and inserting emoticons, Rich text box is provided. All emoticons are available on my local system. Emoticons show up when the mail is written and emoticons inserted, but when the mail is sent, emoticons don't show up on recipient's machine.
Can Alternate views and Linked Resources be used to insert emoticons dynamically or is there any other way to do this.
Thanks in advance
|
|
|
|
|
Vivek Bhatnagar wrote: All emoticons are available on my local system...emoticons don't show up on recipient's machine
Should be clue here don't you think? You will have to embed the images or link them to an external resource that is available to the recipient
only two letters away from being an asset
|
|
|
|
|
Wouldn't the email also have to be HTML for images to show?
Otherwise wouldn't they just be an attachment?
|
|
|
|
|
Sorry, that was a given, didn't think I needed to mention the obvious
only two letters away from being an asset
|
|
|
|
|
from the OP I didn't know if he knew that, assuming he used a RTB I think he may have forgot that, which is why I was asking...
|
|
|
|
|
Suppose your site is abc.com.
Now in your mail the path for the emoticons should be
http://www.abc.com/images/a.jpg
not images/a.jpg
Try using it, i think it will solve your problem
|
|
|
|