Getting While and Thread Problem | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Getting While and Thread Problem
Avatar
iamsaanvi
Hyderabad
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
1
November 2, 2017 - 4:00 am
sp_Permalink sp_Print sp_EditHistory

Hi,

we are using Thingspeak for and IoT app, I'm trying to send data to the portal with the code below.

Lo que sucede es que el ciclo funciona 2 veces, después señala la línea de "ThingSpeakResp" y dice que se excedió el tiempo de espera de la operación. Lo que se me hace raro pues envía los datos y funciona normal las dos primeras veces.

The problem is that the while just work 2 times, after sendig the second data the program stops and says that "ThingSpeakResp" has timed out.

 

using System;
using System.Threading;
using System.Net;

namespace Prueba
{

class MainClass
 {
 const string WRITEKEY = "XXXXXXX";
 const int updateInterval = 17000;
 public static void Main(string[] args)
 {
 while (true)
 {
 delayLoop(updateInterval);
 string strUpdateBase = "http://api.thingspeak.com/update";
 string strUpdateURI = strUpdateBase + "?api_key=" + WRITEKEY;
 string strField1 = "-10";
 HttpWebRequest ThingSpeakReq;
 HttpWebResponse ThingSpeakResp;
 strUpdateURI += "&field1=" + strField1;
 ThingSpeakReq = (HttpWebRequest)WebRequest.Create(strUpdateURI);
 ThingSpeakResp = (HttpWebResponse)ThingSpeakReq.GetResponse();
 
 }
 }

static void delayLoop(int interval)
{
 long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
 int offset = (int)(now % interval);
 int delay = interval - offset;
 Thread.Sleep(delay);
 Console.WriteLine(delay);
}

}
}
<span class="pun">

</span>

This is the console response

Loaded Assembly 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.resources\v4.0_4.0.0.0_es_b77a5c561934e089\System.resources.dll'
Loading module C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.resources\v4.0_4.0.0.0_es_b77a5c561934e089\System.resources.dll in application domain 1:Prueba.exe

Failed to load pdb for assembly C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.resources\v4.0_4.0.0.0_es_b77a5c561934e089\System.resources.dll. Error code E_PDB_NO_DEBUG_INFO(0x806D0014)
Loaded Assembly 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_es_b77a5c561934e089\mscorlib.resources.dll'
Loading module C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_es_b77a5c561934e089\mscorlib.resources.dll in

application domain 1:Prueba.exe
Failed to load pdb for assembly C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_es_b77a5c561934e089\mscorlib.resources.dll. Error code E_PDB_NO_DEBUG_INFO(0x806D0014)

 

 
Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

dannymm1

KamorkasOr

GRV2903

Jusikaclaiz

Raymondpoers

ScottDus

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee