|
Is this the answer to my problem, to google for some key words? Smart answer. So, we can throw away such kind of forums and use only google search. Thanks for the useful answer, it helped alot.
|
|
|
|
|
|
|
Good Morning,
I have a C# desktop application in VS10. I want to able to use an online search engine to retrieve information. I use the following code to call a webpage from the desktop:
string getPage = "http://www.theWebpage.com/";
System.Diagnostics.Process.Start(getPage);
Once I am on that page, I want to pass the information from a textbox on my application directly to a search box on the webpage. Now, I can obviously do this by cutting and pasting the info into the webpage, but what I was wondering if I can have it load the info into the search box automatically when the page loads. The closest I can come now is to automatically copy the info from the textbox using the copy function, but that still requires to user to click and paste. I know how to do this from webpage to webpage but I have never done it from a desk application before. Can it be done? Thank You...Pat
|
|
|
|
|
PDTUM wrote: string getPage = "http://www.theWebpage.com/";
System.Diagnostics.Process.Start(getPage);
string getPage = "http://www.thewebpage.com/?=" + LabelName.Text;
Edit: Added missing "=" sign and put code in code block.
Frazzle the name say's it all
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods
modified 29-Mar-13 8:12am.
|
|
|
|
|
Hello programmers, I am still green programmer.
I got a task to which I have encoded information and
present all information a total of eight characters
I can not think and can not find any alternatives appeal to you
can you help me?
Yours sincerely Modestas
|
|
|
|
|
Start here[^], and also here[^].
Use the best guess
|
|
|
|
|
Maybe this should be in the algorithms forum?
Are you talking about using some sort of hashing algorithm to represent things as an eight character string?
|
|
|
|
|
PIEBALDconsult
Thanks for the offer. This is something like what you are saying.
8 length string has to show all the information.
Thanks again.
|
|
|
|
|
That doesn't really offer any more detail.
|
|
|
|
|
Encode your information in a text file on the web, then use tinyurl.com to get an 8-character url reference to it.
|
|
|
|
|
Hi Braniacs
I have a performance optimization problem that has been bothering me for some time. I have tried to squeeze more performance from it without much success.
The system (simplified) is as follows:
1) Requests come in over an HTTP Post (I need to respond syncronously / inline)
2) I process the request, and return a response (all xml)
3) If I do not have a result ready within 15 seconds, I respond with a 'server busy, try later' type message.
As the central message processing mechanism I have used a Task based approach to queue, start and wait for messages (max of 15 seconds)
When a message is processed almost instantanesouly, the throughput (requests per second) is quite good (1000/s). However, when message processing is delayed by 200ms, this
degrades rather badly to 40/s
A few snippets:
public void AddMessage()
{
Task.Factory.StartNew<MessageResponse >(() =>
{
return worker.ProcessMessage(),
,
TaskCreationOptions.None);
}
public MessageResponse GetMessage()
{
task.Task.Wait(15 * 1000);
switch (task.Status)
{
case TaskStatus.Running:
message = "Your request is taking longer than usual"
case TaskStatus.RanToCompletion:
message = (MessageResponse)task.Result;
}
return message;
}
Note:
Task creation options None / Longrunning / PreferFairness has no impact. When running the visual studio performance analyser, I can visually see Longrunning creating a new thread for each request (expected), and None using a limited number (underlying threadpool) to service the requests.
Looking at both ANTS performance profiler and Visual studio Performance analyzer, there are no concurrency issues around contention and no other obvious areas where time is being wasted (either cpu time or wall clock time)
What is clear from the visualized results is that in a situation where say 1000 requests are queued, 90% of the program time is spent on thread servicing and context switching (obviously very expensive). My conclusion is that waiting on the result (over multiple requests) is very costly.
If i doing this on a web page or WPF form I could make it completely asyncronous, however I dont have this option.
Is there any where I can alter the message processing mechanism to optimize concurrency better? I am open to anything really , would even explore async / await if it would benefit.
Thanks in advance
|
|
|
|
|
my main problem is when i add dynamically a progressbar on flowLayoutPanel1 for each request then how can i increase right progressbar value frombackgroundWorker1_ProgressChanged event
when user click on start button then i will call RunWorkerAsync function of background worker....it is fine. here i am writing a sample code and try to show my problem.
my form has one textbox, one button and one flowLayoutPanel1 with FlowDirection topdown.
when user enter any url in textbox and click on start button then i will start file download with BackGroundWorker and add one progress bar dynamically on flowLayoutPanel1. 10 file can be downloaded at a time. so when user enter ten url one after after one and click on submit button then ten file will be downloading in background.
my problem is how to increment 10 progress bar progress properly from backgroundWorker1_ProgressChanged event another issue is when any file download will complete then the progress bar for which it has been created will be removed from panel
here is my full code. please have a look and tell me what i need to do to achieve my task. if anyone see there is problem in my code for which a dead lock may appear then also please guide me how to avoid dead lock. here is my code
public partial class Form1 : Form
{
static int pbCounter = 1;
public Form1()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
ProgressBar pb = new ProgressBar();
if (pbCounter <= 10)
{
pb.Width = txtUrl.Width;
flowLayoutPanel1.Controls.Add(pb);
pbCounter++;
System.ComponentModel.BackgroundWorker backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
backgroundWorker1.RunWorkerAsync();
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
System.ComponentModel.BackgroundWorker worker = sender as System.ComponentModel.BackgroundWorker;
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
else if (e.Cancelled)
{
}
else
{
pbCounter--;
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.progressBar1.Value = e.ProgressPercentage;
}
}
tbhattacharjee
|
|
|
|
|
Hi,
I updated your code and it should work, but I didn't test it, so you have to try it out.
public partial class Form1 : Form
{
static int pbCounter = 1;
int counter = 0;
public Form1()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
ProgressBar pb = new ProgressBar();
if (pbCounter <= 10)
{
pb.Tag = counter++;
pb.Width = txtUrl.Width;
flowLayoutPanel1.Controls.Add(pb);
pbCounter++;
System.ComponentModel.BackgroundWorker backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.RunWorkerAsync(counter);
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
System.ComponentModel.BackgroundWorker worker = sender as System.ComponentModel.BackgroundWorker;
worker.ReportProgress(<percentToReport>, e.Argument);
e.Result = e.Argument;
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
else if (e.Cancelled)
{
}
else
{
pbCounter--;
ProgressBar barToRemove = null;
foreach (object control in flowLayoutPanel1.Controls)
{
ProgressBar bar = control as ProgressBar;
if (bar != null && bar.Tag == e.Result)
{
barToRemove = bar;
break;
}
}
if (barToRemove != null)
{
flowLayoutPanel1.Controls.Remove(barToRemove);
}
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
foreach(object control in flowLayoutPanel1.Controls)
{
ProgressBar bar = control as ProgressBar;
if (bar != null && bar.Tag == e.UserState)
{
bar.Value = e.ProgressPercentage;
break;
}
}
}
}
Hope this helps,
Thomas.
|
|
|
|
|
thanks
tbhattacharjee
|
|
|
|
|
You're welcome
|
|
|
|
|
I've got the following code that did seem to be working successfully: (It's sending a SOAP envelope to a Java web service and receiving a response) EndPoint is just a string property containing the URL and path to the WebService, Response is a HttpWebResponse property, that other classes use to process the response SOAP.
HttpWebRequest req = (HttpWebRequest) WebRequest.CreateDefault(new Uri(EndPoint));
req.ContentType = "text/xml; charset=utf-8";
req.Method = "POST";
req.Accept = "text/xml";
req.KeepAlive = false;
req.Timeout = Timeout;
req.Proxy = WebRequest.GetSystemWebProxy();
req.Headers.Add("SOAPAction", EndPoint);
using (StreamWriter stm = new StreamWriter(req.GetRequestStream(), Encoding.UTF8))
{
stm.Write(soapRequest.ToString(SaveOptions.DisableFormatting));
stm.Flush();
}
Response = null;
try
{
Response = ((HttpWebResponse) req.GetResponse());
using (StreamReader reader = new StreamReader(Response.GetResponseStream(), Encoding.UTF8))
ResponseString = reader.ReadToEnd();
}
catch (WebException we)
{
throw new ApplicationException("A web exception occurred in calling Transact OUG!\r\n" + we.Message, we);
}
catch (Exception e)
{
throw new ApplicationException("A general exception occurred when calling Transact OUG!\r\n" + e.Message, e);
}
finally
{
if (Response != null)
Response.Close();
req = null;
}
Now I'm not sure what's really changed but I'm getting really odd errors like 'An operation was attempted on something that is not a socket', now I think this might be threading related. As I'm seeing the very first time it returns a timeout, its only the second attempts that I get the odder errors.
As I said this code was working fine when it was called via a single Window WPF app, I've since changed the app to be two hosted UserControls. These don't interact and both have separate ViewModels, but they do both call this method at some point (not simultaneously though).
So my question is have I made some silly mistakes in the above code? Is there anything I should be aware of?
|
|
|
|
|
I made a DirectSound recording program, but the sound is too small. How can amplify sound?
|
|
|
|
|
Better make sure that the recording device uses best Volume, and the user keeps the microphone in an apprpriate distance from his mouth.
It is possible to access the audio samples of the recorded file, and to multiply its values by some factor (make sure you do not get higher values than accepatble for oyur sampling depth). But the sound quality will be bad.
|
|
|
|
|
Thank you for your reply! But I'm not very understand! I don't know how to amplify sound, colleagues guarantee quality!
|
|
|
|
|
What Bernhard said was, "Forget amplifying it. If you amplify a bad recording will will only get a louder bad recording". You cannot compensate for bad recording by making it louder. Do the recording correctly and you don't need to worry about it.
You have to multiple the samples by a scaling factor, the result of which cannot exceed the sample range of your recording setup.
|
|
|
|
|
i have these errors and i cant fix them. i use crystal reports in c# visual studio.
1)
Error 4 The type or namespace name 'ReportClass' could not be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\Visual Studio 2010\Projects\version1\WindowsFormsApplication1\WindowsFormsApplication1\CrystalReport1.cs 19 35 WindowsFormsApplication1
2)
Error 1 The type or namespace name 'CrystalDecisions' could not be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\Visual Studio 2010\Projects\version1\WindowsFormsApplication1\WindowsFormsApplication1\CrystalReport1.cs 14 11 WindowsFormsApplication1
3)
Error 4 The type or namespace name 'ReportClass' could not be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\Visual Studio 2010\Projects\version1\WindowsFormsApplication1\WindowsFormsApplication1\CrystalReport1.cs 19 35 WindowsFormsApplication1
4)
Error 10 The type or namespace name 'ICachedReport' could not be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\Visual Studio 2010\Projects\version1\WindowsFormsApplication1\WindowsFormsApplication1\CrystalReport1.cs 93 52 WindowsFormsApplication1
can you help me pls??
|
|
|
|
|
Make sure you have the right crystal report components installed.
If you use Visual Studio Express, you won't get these components in any case.
|
|
|
|
|
If you have the correct components you need to add them to your project (right click - add reference) and also use them (top of your class using ....;)
|
|
|
|
|
I find the problem ...
i put the choice framework 4 in my properties of visual studio and it stop have a problem..
thanks
|
|
|
|