Getting While and Thread Problem | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Getting While and Thread Problem
No permission to create posts
November 2, 2017
4:00 am
Avatar
iamsaanvi
Hyderabad
New Member
Members
Forum Posts: 1
Member Since:
November 2, 2017
sp_UserOfflineSmall Offline

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: Hans, agrisensezm
38 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Archieter, JamesExedo, IrbosHich, brodi, kasko, franklin castro

Administrators: Hans: 387, lee: 457