System.Net.WebRequest.BeginGetRequestStream C# (CSharp) Method

BeginGetRequestStream() public method

public BeginGetRequestStream ( System callback, object state ) : System.IAsyncResult
callback System
state object
return System.IAsyncResult
        public virtual System.IAsyncResult BeginGetRequestStream(System.AsyncCallback callback, object state) { throw null; }
        public virtual System.IAsyncResult BeginGetResponse(System.AsyncCallback callback, object state) { throw null; }

Usage Example

示例#1
0
        private async void SpeakAppBr_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Sorry! I only listen to you in English!");

            strLngFrom      = "en";
            btnFrom.Content = "English";

            this.speechRecognizer.Recognizer.Grammars.Clear();
            this.speechRecognizer.Recognizer.Grammars.AddGrammarFromPredefinedType("message", SpeechPredefinedGrammar.Dictation);
            await this.speechRecognizer.Recognizer.PreloadGrammarsAsync();

            try
            {
                SpeechRecognitionUIResult recognitionResult = await this.speechRecognizer.RecognizeWithUIAsync();

                if (recognitionResult.ResultStatus == SpeechRecognitionUIStatus.Succeeded)
                {
                    strTextToTranslate = recognitionResult.RecognitionResult.Text;
                    String strTranslatorAccessURI = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
                    System.Net.WebRequest req     = System.Net.WebRequest.Create(strTranslatorAccessURI);
                    req.Method      = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    IAsyncResult writeRequestStreamCallback = (IAsyncResult)req.BeginGetRequestStream(new AsyncCallback(RequestStreamReady), req);
                    txtToTrans.Text = recognitionResult.RecognitionResult.Text;
                }
                else
                {
                    //MessageBox.Show("Sorry! I didn't catch you.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
All Usage Examples Of System.Net.WebRequest::BeginGetRequestStream