|
HI...
I managed searching in google to make a call to a server which returns me data from different GPS devices so I can save to a database. The problem is that I need to do the same but in two different server at the same time, ie, I need to get data from two different URL and save them in my database.
This is what I achieved.
try
{
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://xxx.xxx.xxx.xxx:7778/online?user=xx&pass=xxx");
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
//int count = 0;
//string tempString = "";
Thread t = new Thread(delegate() { Go(buf, resStream, listaRelojes); }); // No need to explicitly use ThreadStart
t.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
public void Go(byte[] buf, Stream resStream, LinkedList<reloj> listaRelojes)
{
int count = 0;
string tempString = "";
tempString = Encoding.ASCII.GetString(buf, 0, count);
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
Parse(tempString, listaRelojes);
System.Console.Out.WriteLine("my System: " + tempString);
}
} while (count > 0);
}
I need something like this I think :
WebRequest.Create("http://xxx.xxx.xxx.xxx:7778/online?user=xx&pass=xxx"); and
WebRequest.Create("http://yyy.yyy.yyy.yyy:7779/online?user=yy&pass=yyy");
at the same time.
Is this posible???
Thank´s in advance.
Christian...
|
|
|
|
|
If you can open up two different browser instances, and successfully issue those URL requests in each of them simultaneously, I see no reason why two WebRequests wouldn't work equally well. However, I never did anything of that kind.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Try threading with BackgroundWorker, Threads or CCR. I have done it myself on a recent project using CCR. But at first instance i suggest you give the BackgroundWorkers a shot.
Regards
Jens
When in trouble,
when in doubt,
run in circles,
scream and shout
|
|
|
|
|
You can create the two requests as you like and then call BeginGetResponse() on each of them (MSDN Reference[^]).
This will probably be the easiest way to get what you want without getting entangled with thread pools (and possible starvation).
|
|
|
|
|
Hello,
I need to determin the COM component(unmanaged code) type and invoke the exposed interface's methods using reflection in C#.NET at runtime.
1 -- First What member of "Type" tells that type is COM component and we can take CLSID at runtime? Is Type.COMObject?
2 -- I need to call methods of exposed interfaces as they called in unmanaged code using CoCreateInstance by passing CLSID and REFID ... I am using InvokeMember but it returns null or 0 as out parameter.
How to pass out parameter in this case.? Is there any need to pass out parameter? As all my COM unamanged code suppose to take las parameter as an OUT parameter and after executing it puts the result into that out param. But I've converted all my unmanged COM code to .NET managed assemblies using tlbimp.exe.
Regards
Usman
|
|
|
|
|
1.You could use Type.IsCOMObject to determinate if this is an instance of COM object.
2.You could get Syste.Type instance by using Type.GetTypeFromCLSID or Type.GetTypeFromProgID .
You really needn't to call CoCreateInstance you could just use
System.Activator class instead of and Marshal.FinalReleaseComObject to free it.
Life is a stage and we are all actors!
|
|
|
|
|
Hello,
I just completed a C# application (VS 2008) and was attempting to put an icon in the bar when I got an unusual error message. It states that the Icon argument will only accept a picture as an icon, even though the menu is calling for an .ico file. I have tried a few different files just to be sure, but all derive the same message. There is a default icon already loaded and I need to replace it. Although this is just a click and install item, I am baffled (and almost embarrassed) as to why I am getting this message and I am unable to load a file. Please tell me what I have missed....?? Thank you, Pat
|
|
|
|
|
is the .ico file and actual icon (or just a renamed bitmap). It may be worth checking in an icon editor ([^])
|
|
|
|
|
Thank you Martin,
Not sure how that could have happened, but you are exactly correct. Apparently, the file was marked as an Icon but the application did not recognize it as one. I appreciate your help and have marked your answer as the correct solution.
Best regards, Pat
|
|
|
|
|
Thanks to everyone for you help in advance.
I have a Grid that currently has a column that does not fill with data from the db but with an image depending on a condtion met. What is the same method but not a rendering method that draws a graphic but rather fills cell with text.
something like:
if (D.Flags == 1)
{
........?? //Draw Text = "Warning"
}
namespace Freepour.Studio.Controls.Grid
{
public class InventoryWorksheetGridImageColumn : GridImageColumn
{
.....
protected override void DrawCell(Divelements.SandGrid.Rendering.RenderingContext context, GridRow row, object value, Font rowFont, Image image, Rectangle bounds, bool selected, Divelements.SandGrid.Rendering.TextFormattingInformation textFormat, Color foreColor)
{
float x = (2) + bounds.Left;
float y = (1) + bounds.Top;
float width = 16.0F;
float height = 16.0F;
object O = row.DataItem;
DownloadAudit D = O as DownloadAudit;
if (D.Flags == 1)
{
context.Graphics.DrawImage(ExclusionImage, x, y, width, height);
}
|
|
|
|
|
This question applies to VB.net and C# so I posted it here in the hope I will get more answers. However, the code will be presented in VB.net. Feel free to respond in C#
The program bellow trhows an error in the line "mTable2 = mTable.Copy". The error is: "Unable to cast object of type 'System.Data.DataTable' to type 'InherintanceQuestion.InheritedTable". This is because mTables is an instance of the InheritedTable class which inherits a DataTable and mTable is a DataTable. So, is there any way I can create the mTable2 to the mTable.copy to the mTable.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mTable As New DataTable
Dim mTable2 As New InheritedTable
mTable.Columns.Add("Col1", System.Type.GetType("System.String"))
mTable.Columns.Add("Col2", System.Type.GetType("System.String"))
Dim Row As DataRow = mTable.NewRow
Row(0) = "A" : Row(1) = "B" : mTable.Rows.Add(Row)
Row = mTable.NewRow
Row(0) = "C" : Row(1) = "D" : mTable.Rows.Add(Row)
mTable2 = DirectCast(mTable.Clone, InheritedTable).Copy
End Sub
End Class
Public Class InheritedTable
Inherits System.Data.DataTable
Private Sub DoSomething()
'Any code.
End Sub
End Class
|
|
|
|
|
for VB, it would be
mtable2 = mTable as DataTable
(or maybe use CType() )
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
you can't do that. An instance of InheritedTable is a DataTable by its very definition; the reverse is not true: when MS created the DataTable class, they did not know about your InheritedTable. Theirs is a rather general-purpose class, yours is more specialized, probably needing more members (data fields, methods), which take memory to store, and that extra memory does not exist inside an instance of the general-purpose DataTable.
So there is no way to promote/specialize an existing DataTable; all you can do is create a new instance of InheritedTable, one that copies the original DataTable content; you could give InheritedTable an extra constructor for this purpose.
If you want a Cat, don't order a Mammal, and hope for some magic; just order a Cat.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
But I can still assign it to ISkinnable, right?
|
|
|
|
|
Yes[^], but you won't get everyone's sympathy.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Ah, that's what I like to see, a shaved p....
|
|
|
|
|
PIEBALDconsult wrote: a shaved p....
You'll want to make that IEdible, as well, I assume.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Yes, because this.Lick ( this ) throws NotImplementedException.
|
|
|
|
|
Bummer...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
But not ISwingable.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You could create a constructor for InheritedTable that takes a DataTable as an argument. Although DataTable is already a huge class and Inheriting from it is probably not a good idea anyway. If you are only adding a couple methods consider using Extension Methods[^]
|
|
|
|
|
I want to compare two images to see if the second image appears within the first. I had thought about the pixel by pixel comparison but there are a lot of variable involved. The facts are these:
1. The first image is a large picture, an orienting picture as it were.
2. The second picture will exist in the first picture, but it will likely be a close up of something in the first picture, could be a slightly different angle as well.
So the pixels won't be the same. Should I reduce the size of the second image in proportion to the first picture and then compare? Will that even make a difference or will the pixel count still remain the same in spite of the resizing.
Can I even pull this off or am I having an LSD flashback from my youth?
--EA
|
|
|
|
|
eddieangel wrote: am I having an LSD flashback from my youth
I don't know about that but it is entirely possible that you have been watching too much CSI.
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
This is a major research topic. Several companies are working on this subject, e.g. security companies want to recognize people's faces in a crowd; and Google wants to offer a service where they recognize the location you show them through a snapshot; they would extract clues (historic buildings, road signs, whatever) and search huge databases.
For an object present on a small picture to be found on a larger picture, with different scale, different orientation, different illumination, it is hard too; however you have one big advantage: you (claim to) know the object is present. So you might go and scan the large image for significant properties, such as specific colors (with some tolerance), a specific shape, etc. Still, a big challenge.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
For the scope of my work it sounds like more trouble that it is worth. Imagine taking a picture of the side of a house and then a picture of a two inch crack in the side of a house and trying to find where that crack belongs on the picture. I will let the people who have more at stake figure it out.
Thank you for the insight, as always.
Cheers, EA
|
|
|
|