|
If you're looking for the C# equivalent to
<font color="green">
if(fork()) {
<font color="green">
} else {
<font color="green">
} then I have to disappoint you by reporting that the .NET runtime supports no such system-like call.
However, I would challenge the decision to do this by saying, "Hey, that's provedural code out the yin-yang and, since we're ostensibly using an object-oriented framework, then we should seek object-oriented solutions."
Just my 0.02 USD.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Don't know if this is intellisense per se, but when calling a function from within the same class you can type "(" or "," and that tooltip box pops up with the parameter list. Is there anyway to get summary info to display in there?
Example:
The tooltip might show " int MyFunction(int,int) ".
I guess I'm looking to see something like " int MyFunction(int MaxValue,int MinValue) ".
Thanks.
|
|
|
|
|
Hi,
that would need structured comments; here is a C# example:
void logUnformatted(int logLevel, string s) {...}
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.
|
|
|
|
|
Thanks,
But I've been trying that in C++ with no luck. According to some posts it looks like this only 'works' in C#. Anyone know if this is still true? I'm using VS 2008, hard to believe the ability is not there.
Even as is, the xml tags show up in intellisense and nothing has changed in the tooltip.
|
|
|
|
|
Hi,
it works for me in C# and IIRC also in VB.NET
Don't know about managed C++, I suggest you look it up in the documentation.
BTW: there was a recent lounge discussion stating VS2010 did not yet offer Intellisense AT ALL for managed C++ ...
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.
|
|
|
|
|
In vs2008, when u place the cursor over the function's call, it just shows up.
|
|
|
|
|
I'm about to convert an old MFC app that I wrote a long time ago that lets me manage my browser cookies. I was using the WinInet APIs and was wondering if MS has written an interop wrapper for the DLL. No luck so far on MSDN or searching here at CP. It's no big deal to write my own interop wrapper class, but I don't want to reinvent the wheel if it's already been done.
QRZ? de WAØTTN
|
|
|
|
|
Hi guys, Ive got a complex problem that I could really use some help / opinions on.
Iam in the process of extending the webservice class to add some additional functionality that I require.
I have a requirement where I need to write ALOT of public webservices for various things in my application. Natively the webservices return xml which is great for the public side of the interface but I would also like them to have the ability to return something other then xml - say html or CSV.
So I have written some XSLT that will run against the XML output of the webservice and transform it into whatever I require. The problem is I want to be able to switch the output of the webservice form xml to my xslt output by changing the request type for say "text/CustomXSLT". I would like to do this so I dont have to implement 2 methods for each webmethod just to cover my requirement.
To do this I have implemented a method attribute that marks a webmethod also as an xslt method:
[
XSLTMethod ("CaseSearch_HTML_Table.xslt" , typeof (SearchCases))]
I have taken the lead from this code project article (see link below) and implemented a very similar system where by I can intercept the method call and manually invoke the method with reflection and put out the correct response.
Extending an existing ASP.NET Web Service to support JSON[^]
However I have hit a road block. All the input parameters in the request.form collection are strings. To make my extension class generic I will need to either write some kind of generic type marshaller to go from string to value or do something else totally horrid.
Iam so close to getting something working here which has alot of value to me but this could be a show stopper. Iam very new to reflection in .net so iam hoping there is alot i dont understand. I was trying to get the .net source so I can see how the standard webservice class handles this kind of type marshalling and see if there is anything i can reuse but the link to the source on the MS site is down
Thanks in Advance for any help
Mike
|
|
|
|
|
which date should i assign, which safe from user changes
modified on Monday, July 6, 2009 8:26 AM
|
|
|
|
|
vishal lele wrote: Hi I want to use the bios date in my application
They BIOS date? Why would that be any different from DateTime.Now ?
|
|
|
|
|
Additional answer based on your modification:
vishal lele wrote: becase sytem date will may be change by user so it will extend expiry period of application
Changing the system date by the user will update the bios date!
DateTime.Now gets the date from the BIOS.
|
|
|
|
|
You could save the "current" date (on installation) and ask (over the internet) for the current date and time. There's a time-server @ time.windows.com
I are troll
|
|
|
|
|
I have a simple C# exe. It internally has some calls to custom interop. I dont have any problem in executing it manually by either double clicking the exe or thru command prompt, everything works as expected. But the moment i launch it using windows scheduled task it always fails.
Is this a know problem with interop calls, when an executable runs thru scheduled task? it fails at the point where i make a method call on the interop object. BTW i am using W2K.
Any suggestion/solution?
Thanks in advance....
Hariharan.T
|
|
|
|
|
Hariharan.T wrote: Is this a know problem with interop calls, when an executable runs thru scheduled task?
What is the difference between you running it and a scheduled task running it?
Hariharan.T wrote: Any suggestion/solution?
Most likely when you run it, it will be running in the security context of you as a logged in user. When the scheduled task runs it it will most likely be running in the context of what ever the task scheduler is running as, which will be SYSTEM (on Windows 2000)
|
|
|
|
|
Hi all,
Please help me to discern Framework and Platform defination.
Thanks.
|
|
|
|
|
hkim_zoro wrote: Please help me to discern Framework and Platform defination.
Did you mean: What is the difference between a Framework and a Platform?
|
|
|
|
|
Hi Colin,
Yup, I mean what is difference between A Framwork and Platfrom?
so, can you give me the definition of each?
Thanks you so much
|
|
|
|
|
What is the best way to update many UI elements from many other threads, in a multi-threaded Windows desktop app?
Currently, I use delegates, which creates many temporary threads. Should the UI be on its own thread rather than the "main" thread? Would a queue pattern be better?
Thanks.
|
|
|
|
|
Well, the UI thread is the main thread, so you can't really make it another thread. I would assume (but don't know for sure) that when you do Control.BeginInvoke or similar, it doesn't create another "temporary thread" since the whole thing with controls is that anything that changes them has to run on the main thread. As far as running a bunch of temporary threads, that's what the ThreadPool was designed to do, so using it should be just fine.
|
|
|
|
|
There is a world of difference between performing BeginInvoke on a delegate, and performing it on a control (passing a delegate as a parameter). IMHO, using the same name for both methods was a mistake, but what's done is done.
Performing BeginInvoke on a control will not create a new thread, nor take one from the thread pool, but will instead post a message in the control's UI thread's event queue. There is no particular limit to the number of messages that can be posted in the event queue, but one should nonetheless limit the number of unprocessed messages one will post to the event queue. Otherwise, if the UI thread gets blocked for some reason, such messages may accumulate without bound.
My particular coding style is to use an UpdateNeeded variable (declared as Integer, but functionally a Boolean) which is set to 0 at the beginning of the control's update routine. When I'm considering updating a control, I Threading.Interlocked.Exchange the variable to 1 and see if it wasn't already 1. If so, I perform a BeginInvoke on the control. If the BeginInvoke fails, I set the variable to 2 (so the control's update routine will know that the control needs updating, but other attempts to update the control will retry the BeginInvoke).
This style assumes that (1) if there are many changes to a control's value before an update takes place, all but the last should be ignored; (2) it is acceptable to update the fields associated with a control while it's being drawn, provided that one performs another update after the current one completes; (3) a redundant control update (e.g. because a field was changed after the update routine started to draw a control, but before the field's value was sampled) will be harmless; (4) updating controls every time the value changes will not cause excessive CPU loading.
If these assumptions hold, the code is fairly straightforward. If they do not, things are more complicated.
|
|
|
|
|
Thanks to both Gideon and supercat9 for these thoughtful replies.
I've been doing this:
Delegate Sub WhateverModel(PassedIn as SomeType)
Private Sub Whatever (PassedIn as SomeType)
If SayForExampleATextBox.InvokeRequired Then
Dim ThisSub as WhateverModel (AddressOf Whatever)
SayForExampleATextBox.Invoke (ThisSub, New Object() {PassedIn})
Else
'do whatever to any control in the same thread as SayForExampleATextBox
End If
End Sub
So I'll be thinking about what you said, supercat9, to be absolutely sure that I don't build up a whole bunch of pending requests on the UI and block the app's processing of these. In fact I have noticed some flakiness that would fit that description.
(I get the idea, but if you have a code snippet to help me see more clearly how to implement this, (if you have time), that would be appreciated.)
Here's a related question which should be a no-brainer for you: My testing shows that doing things like setting checkboxes and radiobuttons checkstate, as well as ProgressBars, text in textboxes, etc, all require Invoke-ing. However, it seems that Invalidate() - RePaint does not. In fact, if I use the above strategy to do (only) a repaint, I get weird behaviour. So I'm not doing the repaint via the delegate. (In case you're wondering what needs repainting, it's a UI with many little "indicator lights" that get bright or dark based on activities on other threads. Because there are so many and their updates are so frequent, this whole issue has come to light.)
|
|
|
|
|
If you use "Invoke" rather than BeginInvoke, there's no need to avoid queueing up lots of messages, because Invoke will wait until the UI-thread action actually occurs. I generally avoid doing that, though, because there's no guarantee of a timely response from the UI thread. In some situations, it will be necessary for the main thread to wait for the UI thread, but in many cases it would be better for the main thread not to do so.
I never do anything to controls outside of the UI thread. Having to Invalidate and Update them and then have the control.Paint event redraw them is annoying, but seems to be the best approach (if you just Invalidate, the control will get redrawn the next time the UI thread is idle; Update will force an immediate redraw of those parts of the control that have been Invalidated).
BTW, I'm not sure but I believe under the .Net run-time, an Invoke on a control will wait until all pending BeginInvoke operations for the UI thread (not just the control) have completed. That will avoid any surprises in sequencing, but could potentially cause the non-UI thread to wait for awhile. If any of the BeginInvoke'd operations have to wait for anything to complete in the thread that called Invoke, deadlock could occur.
|
|
|
|
|
Thanks again supercat9,
May I ask you to elaborate a little on these points:
"use an UpdateNeeded variable" - what is the location and scope of this variable?
"I Threading.Interlocked.Exchange the variable to 1" - where do you do this, before you do BeginInvoke?
"If the BeginInvoke fails" - do you mean you have a try/catch and that under certain circumstances the BeginInvoke returns an exception?
I get your idea of incrementing the variable to indicate that more than one request has arrived, so you could just "use the last one" to do an update. The method you described may be very useful to me, so I just couldn't resist bugging you one more time for more details!
|
|
|
|
|
The proper location and scope of the UpdateNeeded variable will depend somewhat upon the application. For a user-class control that has a single 'update everything' method, it's probably easiest to include the variable within the control's class and then have a public 'update asynchronously' method. For standard controls, it's probably easiest to use an updateNeeded variable within the scope of the parent object (if there are several controls that may independently need to be updated, they should have separate updateNeeded variables).
The Threading.Interlocked.Exchange() is done in an if-test to see if BeginInvoke should be called.
BeginInvoke will throw an unavoidable exception if an object is disposed just before it is called. I'm not sure under what other conditions it may throw an exception, but if for any reason BeginInvoke fails, the updateNeeded variable will never get set back to 0 unless the routine that was supposed to call BeginInvoke resets it.
|
|
|
|
|
Hi all.
I have problem, I use WebBrowser object in my program and I need to get http request (POST/GET).
Someting like this:
POST /path/script.cgi HTTP/1.0
From: example.ge
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 32
home=Cosby&favorite+flavor=flies
|
|
|
|