0

我需要我的应用程序中的数据库名称及其更改。

这是我的代码:

var cancellation = new CancellationTokenSource().Token;

var cnInfo = MyCouch.DbConnectionInfo(serverUrl, "_all_dbs");

cnInfo.BasicAuth = authString;

cnInfo.Timeout = TimeSpan.FromMilliseconds(System.Threading.Timeout.Infinite);

var db = new MyCouch.MyCouchClient(cnInfo);
var changes = db.Changes.ObserveContinuous(MyCouch.Requests.GetChangesRequest
               (
                   Feed = MyCouch.ChangesFeed.Continuous,
                   Since = "0",
                   Heartbeat = 999999999, 
                   IncludeDocs = true,
                   Style = MyCouch.ChangesStyle.MainOnly
               ), cancellation).Take(1).Wait();

几分钟后的第一次尝试会返回数据库名称,但会在下次尝试时阻塞。我可以通过getting http://localhost:5984/_all_dbs.

我很确定我在服务器上有一些数据库。

更新: 订阅更改有效:

db.Changes.ObserveContinuous(MyCouch.Requests.GetChangesRequest
               (
                   Feed = MyCouch.ChangesFeed.Continuous,
                   Since = "0",
                   Heartbeat = 999999999, 
                   IncludeDocs = true,
                   Style = MyCouch.ChangesStyle.MainOnly
               ), cancellation).Subscribe(print); //=> the print works.

主要问题似乎是.Take(1).Wait()。我希望.Take(1)将 an 附加.OnCompleted()到可观察对象,但似乎没有。有什么建议么?

4

0 回答 0