i want to store the webservice method's XML output[the one which we get after invoking the webservice method]. Below is the code which am using and the output that am getting after executing it. Please help to get sort of this....
After adding web reference that consists of webservice URL am using the below code.
my application is written in VB.NET using Visual Studio 2008 and it runs an a Windows CE device, so it uses Compact Framework.
I need to avoid multiple instances of the application and I don't know how to do it.
I have found some solutions but only for the full framework, not for the compact.
Other solutions to this problem talk about mutex: when the application start I should create a mutex if this is the first instance of the application or stop the application if the mutex already exists (or something like this)... but I don't know how to do this.
Sorry for the cross post but this doesn't fit neatly into Silverlight/WPF!
I am asking this in the WPF forum because this is a WPF app but this question does not necessarily pertain to WPF, i.e. the UI thread.
Here is the scenario:
I have three (3) threads. Thread One (1) call it the Master Thread; Thread Two (2) is a Ethernet Comm thread; and Thread Three (3) is a GPIB comm thread. Both communication threads handle asynchronous communications from remote entities. At this time there is only one entity hanging off each comm type.
I have implemented a mix of EventWaitHandles and delegates. This all works pretty well. Just think this architecture is a bit ...... ugly. So which one is better/safer?
My concern is as follows. With delegates, for example, the Master thread registers an event handler with Thread 2 and an event handler with Thread 3 for messages that come in. Obviously data could come in near simultaneously. So Thread 2 encases a message in an EventArg and invokes the event on the Master thread. The Master Thread begins processing and then Thread 3 encases its message in an EventArg and invokes the event on the Master Thread. What happens? Does the Master Thread stop in the middle of handling the first event to service the second one? Does the second event wait until the first event is processed? What if Thread 2 gets another message and invokes the event again while the Master is processing the first event?
I wonder if using a queue and an manual Reset EventWaitHandle is not a better idea as the Thread 2 can check the status and wait until it is reset before putting the message in the queue and setting the EventWaitHandle again.
I have a similar case: multiple threads accessing temperature controllers over a serial port; a temperature charting thread; another handling user interaction.
When I need to access a shared resource (like the serial port), I’ve been using a C# “lock” at the appropriate point to block a competing thread.
It’s been working well and does not require the threads to do anything “special” (other than insure all requests are short in duration so as not to tie up any one thread for an extended amount of time).
Good solution! I am using that in a couple of places and that helps. More I am trying to avoid a mix of EventWaitHandles and delegate/event handlers. I think this is a bit "messy" looking. But with schedule tight sometimes you just have to do what you have to do
OK, I cannot get my head around the whether there is a difference between the 'classic' (perhaps long winded) way of doing it, multiple classes and the 'new' Yield route to (apparently) the same end.
I can understand the classic route (I think), see the code below.
Yield confuses the heck out of me, if I understand it correctly then it's absolutely genius, I get the idea of a state machine (I think) and logically it sort of makes sense but I am not at all confident.
Can it possibly be this simple? You just make that one method as simple or complex as necessary for your situation? (Warning, silly example since arrays can already be enumerated, but it's easy to demo)
Private _Thing AsDouble()
Public Iterator Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
If IsNothing(Me._Thing) ThenThrowNew InvalidOperationException()
EndIfFor Index AsInteger = 0ToMe._Thing.GetUpperBound(0)
What I understand to be the 'old way'.
Private _Thing AsDouble()
PublicFunction GetEnumerator() As IEnumerator(OfDouble) Implements IEnumerable(OfDouble).GetEnumerator
EndFunctionPublicFunction GetEnumerator1() As IEnumerator Implements IEnumerable.GetEnumerator
Private _Thing AsDouble()
Private _Index AsIntegerPrivate _curItem AsDoublePublicSubNew(ByVal Thing AsDouble())
Me._Thing = Thing
Me._Index = -1
Me._curItem = NothingEndSubPublicReadOnlyProperty Current AsDoubleImplements IEnumerator(OfDouble).Current
GetIf IsNothing(Me._curItem) ThenThrowNew InvalidOperationException()
EndGetEndPropertyPublicReadOnlyProperty Current1 AsObjectImplements IEnumerator.Current
EndGetEndPropertyPublicFunction MoveNext() AsBooleanImplements IEnumerator.MoveNext
'If we are already at the end then return false
IfMe._Index = Me._Thing.GetUpperBound(0) ThenReturnFalseEndIf'Otherwise move to the next position in the array
Me._Index += 1Me._curItem = Me._Thing(Me._Index)
ReturnTrueEndFunctionPublicSub Reset() Implements IEnumerator.Reset
Me._Index = -1
Me._curItem = NothingEndSub#Region"IDisposable Support"EndClass
I realise this is a late answer, so maybe you've already figured this out. But maybe it's still worth something, so here goes:
I think the short answer is that Yield is absolutely genius. The 'classic' way as you put it actually is the same implementation over and over again, where only the return value varies. What yield does for you is that it allows you to construct an IEnumerable directly from a function (using Yield statements), such that every time MoveNext() is called, the function takes off where it left off until the next Yield statement.
So, yes, you can just use yield whenever you want I think the only possible issue with it is that it's probably slower than a proper custom ('classic') implementation, so if you have A LOT of elements AND you notice a performance bottleneck in enumeration THEN you might consider getting your hands dirty.
I'm just writing some instructions for installing a .NET COM component.
The first steps are to use regasm and gacutil, but these don't seem to be distributed with the actual framework, and you need to use a version that matches your .NET v or above (i.e. can't use a v2 regasm with a v4 dll).
So I want to say where you can get a copy from, but what 'package' contains these to components? is it the .NET or Windows SDKs?